iOS 不接收来自 Azure 通知中心的推送 [英] iOS doesn't receive push from Azure Notification Hub

查看:59
本文介绍了iOS 不接收来自 Azure 通知中心的推送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我关注了这篇文章:尽管通知中心监视器显示,但仍有一些注册操作和传入消息:

解决方案

很奇怪,但是当我将 Developer Push Certificate 替换为 Production Push Certificate 时,我的应用程序突然开始接收推送!不是Azure的bug吗?猜猜为什么会这样?

In my iOS app I'm trying to add push notifications via Azure Mobile Services.

I have followed this article: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-ios-get-started-push/

But my app still receive no push notifications!

In the iOS dev center I registered App ID with Dev and Production push certificates.

Added Dev certificate (.p12) to Sandbox in the Azure.

I wrote POST function

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 });
        }
    });
};

In the log I'm getting this everytime:

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 }

Also, in the app I register for push:

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

I'm stuck and don't know what to do to make Azure send pushes to my app.

It would be great if anyone could explain me what I'm doing wrong.

Thanks!

UPDATED

I've just found that in Notification Hub Debug tab when I try to broadcast push it shows that there is no registrations: Despite the fact that Notification Hub Monitor shows, that there was some Registration Operations and Incoming Messages:

解决方案

It is strange, but when I replaced Developer Push Certificate with Production Push Certificate, my app suddenly began to receive pushes! Isn't it bug of Azure? Any guess why it happens?

这篇关于iOS 不接收来自 Azure 通知中心的推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆