[英]iOS - Sending Push Notification Image to APNs via FCM not working
[英]Sending APNS push with Azure and Node.js to iOS not working
我需要使用Azure向iOS设备发送推送通知。 我添加了Notification Hub
和p12
证书。
这是我的node.js
代码:
async function sendPush(token) {
var notificationHubService = azure.createNotificationHubService('hub name','connection string');
// registration is done only once:
notificationHubService.apns.createNativeRegistration(token, ['tag_associated_with_token'], null, callback);
var payload = {
alert: 'Hello!'
};
// send notification to all registered devices:
notificationHubService.apns.send(null, payload, null, function(error, response){
if(!error){
console.log('notification sent:');
console.log(response);
}
else {
console.log('error ');
console.log(error);
}
});
}
一切似乎都有效。 我成功注册,在列出我的注册时,我可以看到它在那里。 发送通知有success
响应:
{ isSuccessful: true,
statusCode: 201,
body: '',
headers:
{ 'transfer-encoding': 'chunked',
'content-type': 'application/xml; charset=utf-8',
server: 'Microsoft-HTTPAPI/2.0',
date: 'Wed, 17 Jul 2019 12:43:40 GMT',
connection: 'close' },
md5: undefined
}
就是这样。 看起来一切都很好。 但该设备没有收到通知。
设备令牌是正确的。 该应用程序允许通知。 在Azure门户中设置证书时,我尝试了production
或“沙盒”。 据我所知,一切都应该有效。 我还尝试了门户网站上的测试功能,它报告success
但设备没有得到任何东西。
我错过了什么?
如果您正在开发中使用wifi网络上的手机。 如果是这种情况,您可能需要检查您的路由器是否阻止苹果用于apns沙箱的异常端口。 如果是这种情况,您可能想尝试转发端口:2195 5223.您也可以尝试一起关闭wifi并尝试使用您的蜂窝网络。
希望能帮助到你。
要检查的事情
据我所知,iOS应用程序在推送通知中需要正文和标题。
无论如何,你是否在使用xcode的iOS应用程序中的调试模式下进行测试? 还是只做手工测试?
你用相同的通知格式测试这些吗?
设备正在使用其他库获取通知
请检查这些JSON格式
{
“aps” : {
“alert” : {
“title” : “Game Request”,
“subtitle” : “Five Card Draw”
“body” : “Bob wants to play poker”,
},
“category” : “GAME_INVITATION”
},
“gameID” : “12345678”
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.