未通过 Pushwoosh 在 Windows 通用应用程序 (Windows 8.1) 上接收推送通知

Not receiving push notifications on Windows Universal App (Windows 8.1), via Pushwoosh

我们正在使用 Pushwoosh 服务向我们的应用程序发送推送通知,并且我们已经按照 Windows 8 (javascript) 的教程进行操作。当 运行 在桌面计算机上运行时,我们能够在我们的应用程序中使用推送通知。这是一个 Windows 8.1 通用应用程序,因此我们 运行 我们的 Windows Phone 8.1 版本的代码相同,它也在 javascript.

在Windows Phone 设备中,没有收到推送消息,它经常阻塞在"service.subscribeToPushService();" 方法中。卸载该应用程序并 运行 第一次使用它似乎可行,但之后它就一直阻塞在该方法中。

作为一个通用应用程序,phone 和桌面版本在推送通知方面是否有任何我们应该注意的区别?

您可以阅读有关推送通知的here 主题,其中有一节讨论DOS Attacks 保护。可能与连接重新打开频率有关。

Tip: Refrain from opening and closing the connections to the APNs for each push notification that you want to send. Rapid opening and closing of connections to the APNs will be deemed as a Denial-of-Service (DOS) attack and may prevent your provider from sending push notifications to your applications.

您确定您使用的是最新的 Pushwoosh Windows 8 SDK 吗?如果您使用 Windows/Windows Phone 8.1 的通用应用程序,您将需要为两个平台使用 Pushwoosh Windows 8 (WNS) Pushwoosh SDK。它位于此处:
https://github.com/Pushwoosh/pushwoosh-windows-8-sdk

所有平台的代码应该完全相同: https://github.com/Pushwoosh/pushwoosh-sdk-samples/blob/master/Native/Win8/Win8JS/js/default.js

var service = new PushSDK.NotificationService.getCurrent("YOUR_PUSHWOOSH_APP_ID");

service.ononpushaccepted = function (args) {
    //code to handle push notification
    //display push notification payload for test only
    var md = new Windows.UI.Popups.MessageDialog(args.toString());
    md.showAsync()
}

service.ononpushtokenreceived = function (pushToken) {
    //code to handle push token
}

service.ononpushtokenfailed = function (error) {
    //code to handle push subscription failure
}

service.subscribeToPushService();

另外不要忘记处理启动推送通知:

app.onactivated = function (args) {
    if (args.detail.kind === activation.ActivationKind.launch) {
        showProgress();
        if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated)
        {
            // TODO: This application has been newly launched. Initialize
            // your application here.

            //Handle start push
            PushSDK.NotificationService.handleStartPush(args.detail.arguments);

这里也有同样的信息:
https://community.pushwoosh.com/questions/1801/push-notification-to-windows-81-universal-apps?page=1&focusedAnswerId=1871#1871