We're using Pushwoosh services to send push notifications to our applications and we've followed the tutorial for Windows 8 (javascript). 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.
Being an universal app, is there any difference between the phone and desk top version in terms of push notifications that we should be aware of?
Are you sure you are using the latest Pushwoosh Windows 8 SDK? If you are using Universal app for Windows/Windows Phone 8.1 you will need to use Pushwoosh 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);
Also the same information here:
https://community.pushwoosh.com/questions/1801/push-notification-to-windows-81-universal-apps?page=1&focusedAnswerId=1871#1871