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!
IOS follows proper format for push notification. If you do not follow proper format your notifications won't be delivered. There should be a
apstag also.You can follow this link for reference https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification