node-apn / node-apn

:calling: Apple Push Notification module for Node.js
MIT License
4.39k stars 688 forks source link

Not getting 410 even days after deleting the app #673

Open anand-y opened 4 years ago

anand-y commented 4 years ago

I am not getting 410 status from apns from the past several days and yet haven't succeeded. Wherein I am able to get 400 for the wrong token. Also, I tried both development as well as production environment (via TestFlight). I am using Aws lambda function as my backend and iOS 13. Here is code.

const apn = require('apn');
exports.handler = async (event) => {

let optionsAPNS = {
    token: {
         key: "./AuthKey_T********5.p8",
         keyId: "T********5",
         teamId: "N*********A"
       },
       production: true
     };

 let apnProvider = new apn.Provider(optionsAPNS);

 let body = event['body'] ? JSON.parse(event['body']) : 
 {deviceToken:"94b2f7a2f0c1b158edb2835ccd316592d5d8945892d2b13de143cb4198269d11"};  
 let deviceToken = body.deviceToken;

    var note = new apn.Notification();
    note.topic = "my-bundle-id";
    note.contentAvailable = 1;
    note.sound = "";
    note.pushType = 'background';

    const resdultData =  await apnProvider.send(note, deviceToken);

    let response = {
            "statusCode": 200,
            "headers": {},
            "body": JSON.stringify(resdultData),
            //"body": r,
            "isBase64Encoded": false
        };

    return response;
  };

Please suggest what am I doing wrong or how can I get 410

kmyllyvi commented 4 years ago

Hi. I'm also struggling with the same issue. I'm currently testing with 2-3 days old invalid tokens and haven't been able to get any errors back. Would expect to see 410 error at some point.

There are apparently two interfaces for Apple APN push available; the new HTTP/2 interface, and a legacy binary interface. Can someone verify which one is used by node-apn? For the legacy binary interface additional "feedback service" is apparently needed to get those errors. But this should be somehow already supported by node-apn as the wiki says. Is there something a developer needs to do specifically to enable the feedback service? Thanks for any information on this.

truthhonestmessaging commented 11 months ago

I am trying to figure out when to delete the VOIP tokens. It seems like when getting 403 and 410 is the right time to delete the existing voip tokens in our server. But it seems we are not getting that error code instead getting something like "error": { "jse_shortmsg": "apn write failed: GOAWAY: PROTOCOL_ERROR Stream 5 does not exist", "jse_info": {}, "message": "apn write failed: GOAWAY: PROTOCOL_ERROR Stream 5 does not exist"