0

I'm using node-apn to send push notifications to my device. Whenever I try, I get the following:

    { sent: [],
    failed: 
   [ { device: '****',
   status: '400',
   response: [Object] } ] }

I'm fairly certain my device token is correct. Is there any way to find out more info about why this error occurs. Is there info in the "response"—if so how do I get it? It would be helpful to get one of the error strings listed here (https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) like "BadCollapseId"

Here is my node.js code for reference.

           var deviceToken = "***";
            var notification = new apn.Notification();
            notification.topic = '*****';
            notification.alert = "HI DER";
            notification.payload = {id: 3};
            apnProvider.send(notification, deviceToken).then(function(result) {  
                console.log(result);

            });

The app is built using ionic 2, but I don't think that would make a difference.

Thanks!

Vishnu Murale
  • 173
  • 14

1 Answers1

4

Basically all I needed was this line:

    console.log(result.failed);

instead of

    console.log(result);

This gave me the code "DeviceTokenNotForTopic" and I was able to go from there!

Vishnu Murale
  • 173
  • 14