node-apn / node-apn

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

iOS Push Notification Error: {reason: 'TopicDisallowed'} #715

Closed iamromec closed 1 year ago

iamromec commented 1 year ago

Please read carefully before closing. I'm struggling to resolve notifications for more than a week and still it's half way resolved.

Here is the provider config:

const apn = require('apn'); // version: "apn": "^2.2.0"
const iosOptions = {
  token: {
    key: path.resolve('./lib/AuthK*********.p8'),
    keyId: '*********',
    teamId: '*******'
  },
  production: true
};

const apnProvider = new apn.Provider(iosOptions);
const apnNotification = new apn.Notification();
apnNotification.sound = 'default';
apnNotification.title = 'Hello';
apnNotification.body = 'Hello message';
apnNotification.aps.threadId = 'thread_id';
apnNotification.topic = topic;
apnNotification.payload = payload;

return apnProvider.send(apnNotification, token)

Is there anything wrong with the config?

Error message: reason: 'TopicDisallowed'

Please help if someone knows the solution.

iamromec commented 1 year ago

I have resolved it by replacing the apn package with the @parse/node-apn (npm i @parse/node-apn) package.

iamromec commented 1 year ago

I monitored the results and it seems it wasn't resolved with the parse community package either. Please help.

iamromec commented 1 year ago

Finally, I've resolved it by removing the package and writing a custom notification sender with Apple's official documentation for https://api.push.apple.com.

Here's more: https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW3