我正在使用 Microsoft azure 通知中心在 android 中推送通知。我能够通过 nodejs 服务器代码发送通知。设备从 nodejs 服务器获取通知。
问题:-但是当我使用通知中心时,即使通知中心返回成功代码,通知也永远不会到达设备。
我为通知中心遵循的程序。
步骤-1:- 将 gcmTokenId 注册到我在第一次注册时从我的设备获得的通知中心。
notificationHubService.gcm.createNativeRegistration(gcmToken, tags, function(error){
if(error)
{
res.type('application/json'); // set content-type
res.send(error); // send text response
}
else
{
res.type('application/json'); // set content-type
res.send('Registered Successfully!'); // send text response
}
});
以下是注册详情:-
{
ETag: "1"
ExpirationTime: "2014-09-08T06:33:55.906Z"
RegistrationId: "286469132885875691584-1648906343295271447-3"
Tags: "raj"
GcmRegistrationId: "APA91bF6E2U4*********"
_: {
ContentRootElement: "GcmRegistrationDescription"
id: "id"
title: "2864691328694691584-1648906343295271447-3"
published: "2014-06-10T07:04:30Z"
updated: "2014-06-10T07:04:30Z"
link: ""
}-
}
步骤-2:- 使用以下功能向集线器发送通知。
notificationHubService.gcm.send(
null,
{
data: { message: 'Here is a message' }
},
function (error,response) {
if (!error) {
//message send successfully
res.type('application/json'); // set content-type
res.send(response);
}
});
以下是我从通知中心获得的响应代码。
{
isSuccessful: true
statusCode: 201
body: ""
headers: {
transfer-encoding: "chunked"
content-type: "application/xml; charset=utf-8"
server: "Microsoft-HTTPAPI/2.0"
date: "Tue, 10 Jun 2014 07:07:32 GMT"
}-
}
我在通知中心所做的设置:
- 我在“谷歌云消息设置”中添加了谷歌 API 密钥。
请指导我解决这个问题。