【发布时间】:2014-09-29 19:53:57
【问题描述】:
我在 Azure 中设置了一个移动服务并将其连接到我的 Android 应用程序。通过这个应用程序,我调用 Azure API 将对象插入到链接到移动服务的数据库表中。
我已经编写了在插入之前执行的脚本。该脚本旨在向另一台设备发送推送通知。
现在的情况是,对象被插入到表中,但没有收到推送通知。有什么问题?如何调试?
这是我的插入脚本:
function insert(item, user, request) {
var devices = tables.getTable('Devices');
var receiverHandle;
devices.where({userId: item.receiver}).read({
success: populateHandle
});
request.execute({
success: function() {
// Write to the response and then send the notification in the background
request.respond();
console.log(item);
push.gcm.send(item.handle, item, {
success: function(response) {
console.log('Push notification sent: ', response);
}, error: function(error) {
console.log('Error sending push notification: ', error);
}
});
}
});
function populateHandle(results){
receiverHandle = results[0].handle;
}
}
虽然日志状态推送通知的成功传递。我的设备上没有收到它。
这是其中一个日志:
推送通知发送:{ isSuccessful: true, statusCode: 201, body: '', headers: { 'transfer-encoding': 'chunked', 'content-type': 'application/xml; charset=utf-8', server: 'Microsoft-HTTPAPI/2.0', date: 'Sun, 10 Aug 2014 15:01:52 GMT' }, md5: undefined }
【问题讨论】:
-
我假设您在 Azure 和 Google 上配置了将消息传递到设备所需的所有 GCM 组件?执行此代码时,您是否在控制台中看到任何错误?
-
是的,当然我已经配置了 GCM。哪个控制台我可能会看到错误?
-
在 Azure 管理门户的移动服务中单击“LOGS”选项卡,您将在那里找到条目。
-
那里没有日志!这是否意味着服务器能够毫无问题地发送推送?
-
我会在您的代码堆栈中更早地添加更多的 console.log 语句,以找出代码到达的位置。您的 request.execute 语句没有任何错误块。您还需要检查您的代码,因为我不确定它是否会按照您的预期工作。
标签: android node.js azure cloud