Cordova Windows Phone 8未接收通知(在其他平台上工作)

Cordova Windows Phone 8未接收通知(在其他平台上工作),cordova,azure,windows-phone-8,push-notification,phonegap-pushplugin,Cordova,Azure,Windows Phone 8,Push Notification,Phonegap Pushplugin,我的应用程序是Cordova的,打算在3个平台上运行:Android、Windows和Ios。 在Android上,设备正在注册、发送和接收通知。IOs尚未测试。在windows phone上,我可以发送通知,但无法接收 为了更好地解释我自己,我将把问题分成几个部分 当我打开跨平台解决方案并尝试从以下位置运行时: a) Windows Phone-我收到“引导程序无法连接到计算机” b) Windows Phone Universal-我收到一个警报未定义的错误。既然我们用的是Cordova,这

我的应用程序是Cordova的,打算在3个平台上运行:Android、Windows和Ios。 在Android上,设备正在注册、发送和接收通知。IOs尚未测试。在windows phone上,我可以发送通知,但无法接收

为了更好地解释我自己,我将把问题分成几个部分

当我打开跨平台解决方案并尝试从以下位置运行时: a) Windows Phone-我收到“引导程序无法连接到计算机” b) Windows Phone Universal-我收到一个警报未定义的错误。既然我们用的是Cordova,这就没有意义了。我的意思是,我们使用Javascript能够跨平台运行。 c) Windows Phone 8-它根本不运行。给我一个警告:

警告CS4014由于未等待此调用,因此当前方法的执行将在调用完成之前继续。考虑将“等待”操作符应用到调用的结果。NativeExecution.cs

我决定尝试从特定的平台文件夹(即platforms/WP8目录)运行该程序:我可以从我的应用程序发送推送通知,但无法接收它们

document.addEventListener('deviceready', function () {
mobileServiceClient = new WindowsAzure.MobileServiceClient(
                'https://----------.azure-mobile.net/',
                '------------------------------');

// Create a pushNotification (from the PushPlugin).
pushNotification = window.plugins.pushNotification;

alert(device.platform);

//Platform-specific registrations.
//Here goes Android and IOs registrations

if (device.platform == "Win32NT") {
    var channelName = device.uuid;
    alert(device.uuid);

    pushNotification.register(
        channelHandler,
        errorHandlerWP8,
        {
            "channelName": channelName,
            "ecb": "onNotificationWP8",
            "uccb": "channelHandler",
            "errcb": "jsonErrorHandler"
        });
}
});
因此,当应用程序启动时,它会成功地进入上面的“addeventlistener”,并按预期显示“device.uuid”警报。从那时起,它将使用channelHandler方法注册:

function channelHandler(result) {
    alert('registered### 1' + JSON.stringify(result));
}
当我从不同的设备向同一azure服务发送通知时,我会从Android和Windows 8设备(不是Windows phone 8)(注册到同一服务)收到通知,但不会从Windows phone设备收到通知。这就像通知从一开始就不会进入设备

未触发:警报(device.platform)。设备(uuid)未启动。显然,OnNotification(WP8)方法没有达到

最后,我想,由于通知很可能甚至没有在设备中出现,Azure的todoitem脚本的insert.js方法可能有问题。但是请注意,在我创建并注册到同一服务的windows应用程序上,我成功地接收到以下有效负载的通知。下面是Azure的todoitem的insert.js方法:

function insert(item, user, request) {
    request.execute({
        success: function () {
            var payload = '<?xml version="1.0" encoding="utf-8"?><toast><visual>' +
    '<binding template="ToastText01">  <text id="1">' +
    item.text + '</text></binding></visual></toast>';
        // If the insert succeeds, send a notification.
        push.wns.send(null, payload, 'wns/toast', {
            success: function (pushResponse) {
                console.log("Sent push:", pushResponse);
                request.respond();
            },
            error: function (pushResponse) {
                console.log("Error Sending push:", pushResponse);
                request.respond(500, { error: pushResponse });
            }
        });

        //Define a payload for Android 

        var Androidpayload = '{ "message" : "Notification: ' + item.text + '" }';

        push.send(null, Androidpayload, {
            success: function (pushResponse) {
                console.log("Sent push:", pushResponse);
                 //Send the default response.
                request.respond();
            },
            error: function (pushResponse) {
                console.log("Error Sending push:", pushResponse);
                 //Send the error response.
                request.respond(500, { error: pushResponse });
            }
        });
    }
});
}
函数插入(项目、用户、请求){
请求执行({
成功:函数(){
var有效载荷=“”+
'  ' +
item.text+“”;
//如果插入成功,则发送通知。
push.wns.send(空,有效负载,'wns/toast'{
成功:功能(pushResponse){
日志(“发送推送:”,推送响应);
请求。响应();
},
错误:功能(pushResponse){
日志(“发送推送时出错:”,推送响应);
respond(500,{错误:pushResponse});
}
});
//定义Android的有效负载
var Androidpayload='{“消息”:“通知:'+item.text+'“}';
push.send(空,Androidpayload{
成功:功能(pushResponse){
日志(“发送推送:”,推送响应);
//发送默认响应。
请求。响应();
},
错误:功能(pushResponse){
日志(“发送推送时出错:”,推送响应);
//发送错误响应。
respond(500,{错误:pushResponse});
}
});
}
});
}

我已经想不出问题出在哪里了。任何帮助都将不胜感激

此插件现已弃用。你用过吗?嘿。是的,我开始使用新的插件,但我仍然无法使它在Windows上工作。我最近也在IOS上进行了测试,我也只管理注册,但不接收通知。当通知被认为进入设备时,不会发生任何事情。我还想补充一点:我正在Windows应用商店应用程序和Windows phone平台上注册,但只接收来自Windows应用商店应用程序的通知。此插件现在已被弃用。你用过吗?嘿。是的,我开始使用新的插件,但我仍然无法使它在Windows上工作。我最近也在IOS上进行了测试,我也只管理注册,但不接收通知。当通知被认为进入设备时,不会发生任何事情。我还想补充一点:我正在Windows应用商店应用程序和Windows phone平台上注册,但只接收来自Windows应用商店应用程序的通知