[Please read carefully before answering.]
I'm struggling to resolve notifications for more than a week and still, it's halfway resolved.
- I'm using the production certificate.
- It's working fine sometimes and suddenly starts throwing: { reason: 'TopicDisallowed' }
- It's working perfectly fine on localhost.
- It works fine sometimes on the server too (the issue is unstable). It automatically starts working and stops.
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.