cordova azure 移动应用和通知中心服务

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

我正在创建一个 cordova 项目并使用 azure 移动应用程序 + 通知中心服务。 在 cordova 项目中,我添加了“cordova-plugin-ms-azure-mobile-apps”和“phonegap-plugin-push”插件,但是在运行项目时出现错误:

Failed to load resource: the server responded with a status of 404 - Cannot GET /push/installations/xxxxx(it's a guid string)

设置细节:

phonegap-plugin-push : version="1.7.2" cordova-plugin-ms-azure-mobile-apps : version="2.0.0-beta5" dev tool : visual studio 2015

错误信息图片: enter image description here

var azureClient = new WindowsAzure.MobileServiceClient('http://xxxxxx.azurewebsites.net');

        //PushNotification.
        var push = PushNotification.init({
            android: {
                senderID: "xxx895803xxxx"
            },
            ios: {
                alert: "true",
                badge: "true",
                sound: "true",
            },
            windows: {}
        });

        push.on('registration', function (data) {
            azureClient.push.register('gcm', data.registrationId);
        });

        push.on('notification', function (data, d2) {
            alert('Push Received: ' + data.message);
        });

WindowsAzure.MobileServiceClientcordova-plugin-ms-azure-mobile-apps连接 Azure 移动应用程序和 azureClient.push.register 的插件函数将调用 executeRequestMobileServices.Cordova.js 中发挥作用(cordova-plugin-ms-azure-mobile-apps 插件)

function executeRequest(client, method, pushChannel, content, installationId, callback) {
    Validate.isString(pushChannel, 'pushChannel');
    Validate.notNullOrEmpty(pushChannel, 'pushChannel');

    var headers = { 'If-Modified-Since': 'Mon, 27 Mar 1972 00:00:00 GMT' };
    headers[constants.apiVersionHeaderName] = constants.apiVersion;

    client._request(
        method,
        'push/installations/' + encodeURIComponent(installationId),
        content,
        null,
        headers,
        callback
    );
}

最佳答案

这似乎与移动应用程序或通知中心没有直接关系,而是 Cordova 配置问题。

尝试以下链接之一或 just search :

此外,还有关于如何 Add push notifications to your Apache Cordova app 的分步教程。 .可能有助于验证您所做的是否与教程建议的相似。

关于cordova azure 移动应用和通知中心服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38215862/

相关文章:

azure - 无法将 Microsoft.Azure.Mobile.Server.Authentication 安装到 Xamarin Forms 中

azure - 在 iOS 上使用 Azure 移动服务框架和 swift 时出现问题 - EXC_BAD_ACCESS 将表记录保存到类属性

javascript - 在 PhoneGap 中打开新窗口/文档

cordova - AppBrowser 中的空白页 Cordova ios

javascript - resolveLocalFileSytemURL 返回 FileError {代码 :5}?

ios - 将我的 cordova 项目转移到 Xcode

azure - 将同一域指向 Azure 中的不同应用服务

android - 将文件存储在 Cordova App 的文件夹中

javascript - navigator.geolocation.getCurrentPosition 已停止工作

android - Cordova如何支持Android 7.0引入的Network Security Config?