【发布时间】:2016-03-12 09:33:56
【问题描述】:
我正在尝试开始使用 Azure 移动服务和适用于 Apache Cordova 的 Visual Studio 工具。 (https://msdn.microsoft.com/en-gb/magazine/dn879353.aspx)
我想使用移动服务推送通知。我已经创建了服务,带有一个 Node 后端和一个 TodoItem 表。我也设置了 GCM。
但是,在尝试注册模板时,我收到 404 Not Found 错误:
var GCM_SENDER_ID = 'MY_GCM_ID';
mobileServiceClient = new WindowsAzure.MobileServiceClient(
"MY_URL",
"MY_API_KEY"
);
pushNotification = PushNotification.init({
"android": { "senderID": GCM_SENDER_ID }
});
pushNotification.on('registration', function (data) {
var handle = data.registrationId; //This appears to be set alright
var platform = device.platform; // This is 'Android'
if (platform == 'android' || platform == 'Android') {
var template = '{ "data" : {"message":"$(message)"}}';
mobileServiceClient.push.gcm.registerTemplate(handle, 'myTemplate', template, null);
});
最后一行给了我一个 404。我正在 Google Android Emulator 中运行该应用程序。
编辑:我尝试使用 Postman 调用注册端点:https://myservice.azure-mobile.net/push/registrations?platform=gcm&deviceId=
如果我执行 GET,我会得到 [] 作为响应,如果我执行 POST,我会得到 404
【问题讨论】:
-
你能注意一下你安装的JS文件/插件是什么版本的吗?还有你的 Node.js 服务器是什么版本的?当您点击 x-zumo-version 的任何端点(如表/待办事项)时,都会有一个标题:Zumo.master.0.1.6.4401.Runtime。
-
谢谢。我该如何查看标题?我花了一两天的时间试图让模拟器与 Fiddler 很好地配合,但我似乎无处可去?
-
您可以在 Chrome 上使用 Postman 应用程序,比使用 Fiddler 更容易,并且无需涉及任何模拟器/等。
-
我还意识到 404 可能来自 NH(并通过移动服务路由),因此您可能还需要检查您的日志选项卡。确认 404 来自何处的一种简单方法是在 Push 脚本中添加 console.log()。
-
我的印象是我必须使用模拟器而不是 Ripple / 浏览器,因为还不支持推送通知。另外,请原谅我的无知 - 什么是 NH?
标签: azure-mobile-services visual-studio-cordova