Monday, 8 May 2017

node.js apn Failed to generate token

As title, i use node-apn package to send push notification to iOS devices.

In my local machine (MacOS), i can send notification to device successfully, but when i deploy my codes to a CentOS server, i can't apnProvider object.

My Codes is:

var apn = require('apn')
var path = require('path')

let options = {
  token: {
    key: path.resolve('/path/to/f8/keyfile'),
    keyId: 'myKeyId',
    teamId: "myTeamID"
  },
  production: false
};

var apnProvider = new apn.Provider(options);

I got this error, (i tried google about it but can't find a solution):

/root/buzzship/node.js/node_modules/apn/lib/credentials/token/prepare.js:45 throw new VError(err, "Failed to generate token"); ^ VError: Failed to generate token: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode at prepareToken (/root/buzzship/node.js/node_modules/apn/lib/credentials/token/prepare.js:45:13) at config (/root/buzzship/node.js/node_modules/apn/lib/config.js:42:31) at new Client (/root/buzzship/node.js/node_modules/apn/lib/client.js:11:19) at EventEmitter.Provider (/root/buzzship/node.js/node_modules/apn/lib/provider.js:12:19) at Object. (/root/buzzship/node.js/index-api.js:128:19) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:393:7) at startup (bootstrap_node.js:150:9) at bootstrap_node.js:508:3

Please tell me what i am wrong at, thank you.



via chicken_tombeo

No comments:

Post a Comment