在我的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時,它開始運行良好。 –