Hi,

We've followed the tutorial for Windows 8 (javascript) and we were able to have the push notifications working in our application when running on the desktop computer. This is a Windows 8.1 Universal App, so we run the same code for our Windows Phone 8.1 version, which is also in javascript.

In the Windows Phone device the push message is not being received and it often blocks in the "service.subscribeToPushService();" method. Uninstalling the app and running it for the first time seems to work, but after that it just keeps blocking in that method.

asked 20 Jan '15, 18:59
Marco%20Costa's gravatar image

Marco Costa
112

Are you sure you are using the latest Windows 8 SDK? If you are using Universal app for Windows/Windows Phone 8.1 you will need to use Windows 8 (WNS) Pushwoosh SDK for both platforms. It is located here:
https://github.com/Pushwoosh/pushwoosh-windows-8-sdk

The code should be exactly the same for all platforms:
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();

Also don't forget to handle launch push notification:

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);
permanent link
answered 13 Feb '15, 10:32
shader's gravatar image

shader
3.9k7

Also please note that with this approach Windows Phone 8.1 and Windows 8.1 devices will subscribe under "Windows 8" platform. You can differentiate them by using os_version tag.

(13 Feb '15, 10:34) shader shader's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×26
×21
×3

question asked: 20 Jan '15, 18:59

question was seen: 2,361 times

last updated: 13 Feb '15, 10:34