単一の .pem とパスフレーズのみを使用して apnagent に接続できますか? または、別のキー .pem も必要ですか?
私はさまざまな証明書ファイルとその用途について少し知らないので、私の間違いが .pem ファイルとパスフレーズのみを使用しようとしたのか、それとも他の間違いを犯しているのかはわかりません。
次のコードを実行すると、エラーも正常な応答も返されません。私だけの「イベントを待っている....」
'use strict'
const apnagent = require('apnagent')
const join = require('path').join
const certFile = join(__dirname,'/../certs/mint-APN-dev.pem')
const deviceToken = '<token>'
const passphrase = '<passphrase>'
let agent = module.exports = new apnagent.Agent()
agent
.set('cert file',certFile)
.set('passphrase',passphrase)
.enable('sandbox')
agent.connect(function (err) {
if (err && err.name === 'GatewayAuthorizationError') {
console.log('Authentication Error: %s', err.message)
process.exit(1)
}
else if (err) {
throw err
}
var env = agent.enabled('sandbox')
? 'sandbox'
: 'production'
console.log('apnagent [%s] gateway connected', env)
})
// keep it running for a bit to give it time to succeed or fail
let id = setInterval(function() {
console.log('Waiting for events...')
count++
if (count > 18) clearInterval(id)
}, 5000)