在我的iOS应用中,我试图通过Azure移动服务添加推送通知。iOS没有收到来自Azure通知中心的推送
但我的应用程序还是没有收到推送通知!
在iOS开发中心,我注册了具有Dev和Production推送证书的App ID。
向Azure中的沙箱添加了开发人员证书(.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发送到我的应用程序。
如果有人能解释我做错了什么,那将会很棒。
谢谢!
修订
我刚刚发现,在通知中心,调试选项卡,当我尝试播放推它表明,没有登记: 尽管通知中心监控显示,有在一些登记工作,收到的消息:
很高兴你的工作!如果您正在运行TestFlight或其他临时分发,它将使用生产APN频道。如果您从Xcode运行,则它使用Developer/Sandbox通道。 –
谢谢!因此,这非常奇怪,因为我正在使用XCode运行应用程序,并且可能需要使用Dev证书才能收到应用程序,但是当我将Dev证书替换为Production时,它开始运行良好。 –