parse-community / node-apn

Apple Push Notification module for Node.js
Other
172 stars 61 forks source link

Getting InvalidProviderToken with all valid Key, KeyId and TeamID #144

Closed bebrasmell closed 3 months ago

bebrasmell commented 3 months ago

I'm having 403 "InvalidProviderToken" when sending push notifications. I tried parsing the JWT token it sends and it appears to be parsed alright. Key, KeyID and TeamID are valid and were tested with both Firebase and different library in a separate dotnet service, so that's definitely not the issue.

I tried issuing new keys (Apple allows to have two keys simultaneously) as a second key, but none of them worked. I tried running the code both from Windows and MacOS, so root certificate is not a problem too.

The code (simplified):

const APNProvider = new apn.Provider({
    token: {
      key: Environment.CONNECT_APN_KEY_PATH,
      keyId: Environment.CONNECT_APN_KEY_ID,
      teamId: Environment.CONNECT_APN_TEAM_ID,
    },
  });

  // <... time passes and someone finally decides to send a message to other user ...>

 const res = await APNProvider.send(notification, recipients);
 console.log(res)

So, the response:

{
  "sent": [],
  "failed": [
    {
      "device": "...",
      "status": 403,
      "response": {
        "reason": "InvalidProviderToken"
      }
    },
    {
      "device": "...",
      "status": 403,
      "response": {
        "reason": "InvalidProviderToken"
      }
    }
  ]
}

Am I missing something?

parse-github-assistant[bot] commented 3 months ago

Thanks for opening this issue!

mtrezza commented 3 months ago