appfeel / node-pushnotifications

Push notifications for GCM, APNS, MPNS, AMZ (automatic detection from device token)
MIT License
534 stars 126 forks source link

Error: APN connection not configured properly #101

Closed rdewolff closed 5 years ago

rdewolff commented 5 years ago

Hello

Am finding hard to use the lib with the current doc and the doc of the lib being used (https://github.com/node-apn/node-apn).

I have tested my credentials and they work. But when I use the lib on my minimal node backend with Express, I get the following error : Error: APN connection not configured properly

How can I debug this? What's the error behind?

Any help would be great!

Code extract :

const settings = {
  // Google
   ...
  // Apple
  apn: {
    token: {
      key: '../certs/myCert.p8',
      keyId: 'SUPER-KEY',
      teamId: 'SUPER-TEAM',
    },
    production: false,
  }
}

const push = new PushNotifications(settings)

push.send(
  ['b9251b2cf_xXx_DEVICE_ID_xXx_757a7fe'],
  {
    title: 'Hello!',
    body: 'I am in your phone.',
    topic: 'org.my.app'
  }
)
miqmago commented 5 years ago

Hi @rdewolff the error comes from this line: https://github.com/appfeel/node-pushnotifications/blob/master/src/sendAPN.js#L53

So it's basically that there was an error creating the connection at here: https://github.com/appfeel/node-pushnotifications/blob/master/src/sendAPN.js#L11

This is the point where you could place a console log to see the error.

miqmago commented 5 years ago

In order to improve readability, I've just improved error management: https://github.com/appfeel/node-pushnotifications/releases/tag/1.1.7, please update it to obtain a more descriptive error:

npm i node-pushnotifications@^1.1.7 --save

Reopen the issue if you need more help :)

rdewolff commented 5 years ago

Thanks @miqmago!