iOS没有收到来自Azure Notification Hub的推送 [英] iOS doesn't receive push from Azure Notification Hub

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

问题描述

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

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

我关注了这篇文章: https://azure.microsoft.com/zh-cn/documentation/articles/mobile-services-javascript-backend-ios-get-started-push/

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

But my app still receive no push notifications!

我在iOS开发中心中注册了具有开发和生产推送证书的App ID.

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

将开发证书(.p12)添加到Azure的沙箱中.

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

我写了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 });
        }
    });
};

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

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

我被困住了,不知道该怎么做才能使Azure将推送发送到我的应用程序.

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.

谢谢!

已更新

当我尝试广播推送时,我刚刚在Notification Hub的Debug选项卡中发现它表明没有注册: 尽管Notification Hub Monitor会显示事实,但仍有一些注册操作和传入消息:

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:

推荐答案

这很奇怪,但是当我用生产推送证书替换了开发者推送证书时,我的应用突然开始收到推送!这不是Azure的错误吗?你猜为什么会发生吗?

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 Notification Hub的推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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