parse-community / node-apn

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

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

Closed iamromec closed 2 years ago

iamromec commented 2 years 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('@parse/node-apn'); // version: "@parse/node-apn": "^5.1.3"
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 = data.title;
apnNotification.body = data.message;
apnNotification.aps.threadId = threadId;
apnNotification.topic = topic;
apnNotification.payload = payload;
apnNotification.pushType = 'alert';
apnNotification.expiry = Math.floor(Date.now() / 1000) + 3600;

apnProvider.send(apnNotification, token)

Is there anything wrong with the config?

Error message: reason: 'TopicDisallowed'

PS: I dynamically change provider options to send notifications from multiple team IDs. Is there anything to do with provider.shutdown()? Because I'm not closing this.

As said, it suddenly starts throwing the error, not always. Please help if someone knows the solution.

parse-github-assistant[bot] commented 2 years ago

Thanks for opening this issue!

iamromec commented 2 years ago

This is very critical to us. Please help us in resolving this.

iamromec commented 2 years 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