iOS不会收到来自Azure通知中心的推送

在我的iOS应用程序中,我尝试通过Azure移动服务添加推送通知。

我已经按照这篇文章: https : //azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-ios-get-started-push/

但我的应用程序仍然没有收到推送通知!

在iOS开发中心,我使用Dev和Production推送证书注册了App ID。

在Azure中向Sandbox添加开发证书(.p12)。

我写了POST函数

exports.post = function(request, response) { var text = 'You\'ve just received a push!'; var push = request.service.push; push.apns.send(null, { alert: "Alert", payload: { inAppMessage: text } }, { success: function(pushResponse) { console.log("Sent iOS push:", pushResponse); response.send(statusCodes.OK, { message : 'Push send success' }); }, error: function(error) { console.log("Sent iOS push error:", error); response.send(statusCodes.BAD_REQUEST, { message : 'Push send error: ' + error }); } }); }; 

在日志中我每次都得到这个:

 Sent iOS push: { isSuccessful: true, statusCode: 201, body: '', headers: { 'transfer-encoding': 'chunked', 'content-type': 'application/xml; charset=utf-8', server: 'Microsoft-HTTPAPI/2.0', date: 'Sat, 02 Apr 2016 18:27:42 GMT' }, md5: undefined } 

此外,在我注册推的应用程序:

 if let client = self.azureClient { client.push.registerNativeWithDeviceToken(deviceToken, tags: nil, completion: { (error: NSError?) in if let error = error { print(error) } }) } 

我被卡住了,不知道该怎么做才能让Azure发送到我的应用程序。

如果有人能解释我做错了什么,那将是非常好的。

谢谢!

更新

我刚刚发现,在通知中心debugging选项卡,当我尝试广播推它显示没有注册: 在这里输入图像说明 尽pipeNotification Hub Monitor显示,有一些注册操作和传入消息: 在这里输入图像说明

警报密钥需要位于aps对象内,如下所示:

 push.apns.send(null, { aps: { alert: "Alert" }, payload: { inAppMessage: text } }, .... ); 

苹果有一个关于推送通知有效载荷的页面和更多的例子。

另外请确保您在设备上运行您的应用程序,因为模拟器无法接收通知。

如果您还没有收到通知,请参阅Apple的推送通知的故障排除页面或更新您的问题。

这很奇怪,但是当我用生产推送证书replace了开发人员推送证书时,我的应用程序突然开始接受推送! 是不是Azure的错误? 任何猜测为什么会发生?