iosnode.jspush-notificationpushnode-apn

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


[Please read carefully before answering.]

I'm struggling to resolve notifications for more than a week and still, it's halfway 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.


Solution

  • 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