rs / pushd

Blazing fast multi-protocol mobile and web push notification service
MIT License
1.16k stars 227 forks source link

Receving empty content for WP8 Push messages #69

Open nacho-marin opened 10 years ago

nacho-marin commented 10 years ago

We are currently developing a cross-platform software solution with PhoneGap, using the PushPlugin at client side and pushd for the server side. It is working perfectly for Android and iOS but we are having a problem in Windows Phone 8.

The WP8 app is correctly registering against the MPNS server and then against pushd (for raw notifications). If we launch a PUSH message against a registered device using Microsoft's sample project to send push notifications (http://code.msdn.microsoft.com/wpapps/Raw-Notification-Sample-71a49078), we receive them and can successfully extract the content.

But if we send a notification via pushd as we do for Android and iOS (for instance, curl -d msg=Sending%20PUSH%notification%20WP8 http://localhost:11180/event/nacho) where nacho is an event to which the WP8 app is subscribed, we receive the notification but its content is empty.

In PhoneGap, the callback method for WP8 PUSH messages reception implemented so far is as simple as follows, inspecting the content of the object received in PhoneGap

function xinspect(o,i){ if(typeof i=='undefined')i=''; if(i.length>50)return '[MAX ITERATIONS]'; var r=[]; for(var p in o){ var t=typeof o[p]; r.push(i+'"'+p+'" ('+t+') => '+(t=='object' ? 'object:'+xinspect(o[p],i+' ') : o[p]+'')); } return r.join(i+'\n'); }

function onNotificationWP8(e) { if (e.type == "raw" && e.jsonContent) { alert(xinspect(e.jsonContent.Body)); } }

The alert shows an empty JSON object ("{}"). If we inspect the object e and show its content via an alert and all we find is

emptyrawwp8pushmessage

I'd like to insist that, if we send a message via the sample project at MSDN we properly receive the message...

Maybe we are doing something wrong, but we cannot find where. Has anyone been through this problem before? How could it be solved?

I am willing to improve documentation (README.md) if some steps need to be better document in order to stop others from making the same mistake.

Thanks in advance!