قالب وردپرس درنا توس
Home / IOS Development / Sending APNS push with Azure and Node.js to iOS does not work

Sending APNS push with Azure and Node.js to iOS does not work



I need to send push notifications to iOS devices with Azure. I added Notification Hub and p12 the certificate for it.

This is my node.js code:

  async function sendPush (token) {
var notificationHubService = azure.createNotificationHubService (& # 39; name & # 39 ;, & # 39; connection string & # 39;);

// registration only once:
notificationHubService.apns.createNativeRegistration (token, ['tag_associated_with_token'] zero, callback);

was payload = {
alert: & # 39; Hi! & # 39;
};

// send notification to all registered entities:
notificationHubService.apns.send (zero, payload, zero, function (error, answer) {
if (! error) {
console.log (& # 39; message sent: & # 39;);
console.log (response);
}
otherwise {
console.log (& # 39; error & # 39;);
console.log (error);
}
});
}

Everything seems to work. I get a successful registration, and when I register the registrations, I can see that it is there. Sending the alert has a success :

  {isSuccessful: true,
status code: 201
, body: & # 39; & # 39 ;, headlines: {& # 39; transfer coding & # 39 ;: & # 39; chunked & # 39 ;, & # 39; content type & # 39 ;: & # 39; application / xml; charset = utf-8 & # 39; , server: & # 39; Microsoft HTTPAPI / 2.0 & # 39 ;, date: & # 39; Wed, 17 Jul 2019 12:43:40 GMT & # 39 ;, connection: & # 39; Close & # 39;}, md5: undefined }

And that's it. Looks like everything is good. But the device does not receive notice.

The device token is correct. The app allows alerts. When I put the certificate in the Azure portal, I tried both production or "sandbox". As far as I can see, everything must work. I also tried the Test function on the portal itself and it reports success but the device does not get anything.

What am I missing?


Source link