I'm having issues with node.js sending push notifications, I think because I'm doing something wrong with my APN certificate thats generated in my apple developer account. Im getting this error from Node.js.
VError: Failed to generate token: error:0906D06C:PEM routines:PEM_read_bio:no start line
I'm not sure I've generated the right file in the apple developer account. See below screenshot, when i click download this gives me a "aps.cer" file which is what i'm putting in my node.js project and using with node-app module. Here is how im setting it in my code:
let options = {
token: {
key: "aps.cer",
keyId: "singlemeout.Single-Me-Out",
teamId: "Team Name"
},
production: false
};
Here is a screen shot of my certificate.
You are providing
node-apn
with a token-based configuration, while you are using certificates.If you want to keep using certificates:
the certificate should be in PEM format.
You can do the conversion like this:
you need to provide the key, either by adding it to the certificate, or by providing it as a separate file
you need to use the
cert
,key
and orpfx
properties in your config object rather thantoken.key
etc.Alternatively, you can switch to using tokens.
See https://github.com/node-apn/node-apn/blob/master/doc/provider.markdown for full details.
Also your
production
property is not consistent with the certificate used.