Modreanu Eduard
Modreanu Eduard

Reputation: 263

TopicDisallowed Push Notification

I have a small issue. I am trying to test my push notification feature but I can't figure it out. I set up a webRTC page that I'm using to send the notification (I don't own 2 IOS devices). All the certificates/keys were generated using fastlane actions (match and pem). I am aware I'm using a production feature for the apnOptions and I generated the correct certificates. When I write some gibberish on the key or teamID, I get errors so that means my certificate should be alright. The bundle identifier is exactly the one that appears on the developer Apple page.enter code here

Here are my token and my notification:

 var apnProvider = new apn.Provider({
  token: {
    key: "cert/key.p8",
    keyId: "#",
    teamId: "#"
  },
  production: true
  });


if (deviceToken) {
        if (platform === 'ios') {
          let note = new apn.Notification()
          note.alert = 'Hello World'
          note = Object.assign(note, {
            // Expires 1 hour from now.
            expiry: Math.floor(Date.now() / 1000) + 3600,
            badge: 3,
            payload: payloadBody,
            topic: "org.#.#"
          })

          apnProvider.send(note, deviceToken).then((result) => {
            console.log('APNPROVIDER RESULT', `PLATFORM: ${platform}, RESULT:${JSON.stringify(result)}`)
          })

Thank you very much for your help!

Upvotes: 4

Views: 9932

Answers (5)

rithuwa
rithuwa

Reputation: 45

please check your topic usuually it happens when you entered wrong app bundle id

topic: "add correct bundle id"

check below link as well https://github.com/node-apn/node-apn#sending-a-notification

Upvotes: 0

dpaine
dpaine

Reputation: 23

Double check the Topic Name, I've encountered this problem with a typo in the Topic Name.

Upvotes: 0

Nupur Sharma
Nupur Sharma

Reputation: 1214

In my case, the problem was, Server was taking push kit device token i.e. voIP token, and the bundle id was "com.something".

Solution: For voIP type of notifications user, "com.something.voip" topic/bundle id.

Upvotes: 1

Modreanu Eduard
Modreanu Eduard

Reputation: 263

I found out in the end. It turned out that if I use a voip bundle I need to add at the end of the bundle .voip. So, a bundle would look something like org.test.Test.voip. I'm done..

Upvotes: 5

Shruti
Shruti

Reputation: 1849

IOS follows proper format for push notification. If you do not follow proper format your notifications won't be delivered. There should be a aps tag also.

{
  "aps": {
     "alert": "Hello World",
     "sound": "default"
   },
  "customData": {
    "CustomKey": "CustomValue",
    }
 }

You can follow this link for reference https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification

Upvotes: 0

Related Questions