Cordova Azure - 错误请求 - TypeError:无法读取未定义的属性“listRegistrationsByTag”

时间:2016-05-30 08:55:59

标签: javascript node.js cordova azure azure-devops

对于一个项目,我正在尝试将Cordova应用程序连接到Azure服务。 我按照以下教程:https://azure.microsoft.com/nl-nl/documentation/articles/app-service-mobile-cordova-get-started-push/ 但每次我尝试注册应用程序时,都会给出错误请求异常。奇怪的是我可以在表格中插入数据,所以我知道我的服务已链接到应用程序。

有人建议吗?提前谢谢!

代码:

function onDeviceReady() {
        // Create a connection reference to our Azure Mobile Apps backend
        client = new WindowsAzure.MobileServiceClient("https://xxx.azurewebsites.net"); //endpoint!

        refreshDisplay();
        registerForPushNotifications();

        var item = { test: 'Tesst', complete: false };
        client.getTable('todoitem').insert(item); // <-- this works and item is ïnsterted in the "Easy Table

    }

    /**
     * Refresh the items within the page
     */
    function refreshDisplay() {
        updateSummaryMessage('Waiting for notifications');
    }

    function registerForPushNotifications() {
        // Wire up the UI Event Handler for the Add Item
        // Define the PushPlugin.
        pushNotification = PushNotification.init({
            "android": {
                "senderID": GCM_SENDER_ID
            },
            "ios": { "alert": "true", "badge": "true", "sound": "true" },
            "windows": {}
        });  

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

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

        pushNotification.on('error', function (e) {
            gcmError(e);
        });
    }

在Azure / Visual Studio Team Services输出(VS Online)上:

   2016-05-30T08:32:52.064Z - error:  TypeError: Cannot read property 'listRegistrationsByTag' of undefined
        at listRegistrations (D:\home\site\wwwroot\node_modules\azure-mobile-apps\src\notifications\index.js:78:25)
        at D:\home\site\wwwroot\node_modules\azure-mobile-apps\src\notifications\index.js:75:13
        at Object.module.exports.create (D:\home\site\wwwroot\node_modules\azure-mobile-apps\src\utilities\promises.js:27:16)
        at mapRegistrations (D:\home\site\wwwroot\node_modules\azure-mobile-apps\src\notifications\index.js:71:25)
        at getTagsByInstallationId (D:\home\site\wwwroot\node_modules\azure-mobile-apps\src\notifications\index.js:55:16)
        at Object.putInstallation (D:\home\site\wwwroot\node_modules\azure-mobile-apps\src\notifications\index.js:35:20)
        at put (D:\home\site\wwwroot\node_modules\azure-mobile-apps\src\express\middleware\notifications.js:35:28)
        at Layer.handle [as handle_request] (D:\home\site\wwwroot\node_modules\express\lib\router\layer.js:95:5)
        at next (D:\home\site\wwwroot\node_modules\express\lib\router\route.js:131:13)
        at D:\home\site\wwwroot\node_modules\body-parser\lib\read.js:129:5

在控制台中:

Failed to load resource: the server responded with a status of 400 (Bad Request) https://xxx.azurewebsites.net/push/installations/126c8954-0dfb-d9f1-e9d5-00f922b736a6

0 个答案:

没有答案