azure-mobile-services - 适用于 Cordova 的 Azure 移动服务/VS 工具 - 404

标签 azure-mobile-services visual-studio-cordova

我正在尝试开始使用 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

最佳答案

终于修复了 - 我没有安装 Cordova 白名单插件!

在调试到 MobileServices.Web.js 并看到与 Postman 成功的完全相同的请求在 Android 模拟器中失败后,我意识到。

关于azure-mobile-services - 适用于 Cordova 的 Azure 移动服务/VS 工具 - 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34139378/

相关文章:

使用 Azure 通知中心的 Android 推送通知

azure - 创建没有应用程序 key 的 MobileServiceClient 对象

Android服务导致内存问题

visual-studio-cordova - Visual-studio-cordova 的 VS 2015 CTP 6 中没有空白 Cordova 项目

ios - Visual Studio 2015 远程 iOS 构建服务器设置 - 安全模式问题

android - Apache Cordova 错误的 Visual Studio 工具

azure - Monodroid 与 Windows Azure 移动服务

node.js - Azure 应用服务(移动应用)的共享代码

visual-studio - 'ApacheCordovaToolsPackage' 包没有正确加载

visual-studio-cordova - 在多设备混合应用程序中使用九 block 闪屏