phonegap-build / PushPlugin

This repository is deprecated head to phonegap/phonegap-push-plugin
https://github.com/phonegap/phonegap-plugin-push
MIT License
1.31k stars 996 forks source link

WP8 push notification #255

Open joshilomas opened 10 years ago

joshilomas commented 10 years ago

I have easily applied push notification service for my android app, but confused how to do in windows phone.

if(device.platform == "Win32NT"){ pushNotification.register( channelHandler, errorHandler, { "channelName": channelName, "ecb": "onNotificationWP8", "uccb": "channelHandler", "errcb": "jsonErrorHandler" }); }

I doesn't understand what the above parameters. eg: channelName. where can i get the values for these parameters??

Also, does anyone give me the link to full tutorial applying PNS in wp8 including server side too?

Regards, Lomas Joshi

joshilomas commented 10 years ago

As i understand i can put any value for channelName. But now the problem is that, Inside channelHandler function i get data with channelName and empty uri. what does uri means here? what is problem with my code? Any help??

postixo commented 10 years ago

hi josh, i'm facing the same problem here. i've successfully implemented push notifications for android app with a custom made back office using push plugin and PushSharp.

Now i'm trying implement for wp8 and can't find any support by microsoft or any good tuturial.

if you or anybody find anything let me know please.

Regards

joshilomas commented 10 years ago

Hello postixo, now i have successfully implemented Toast notification for wp8 phone. The uri is the what actually we need for push notification in wp8 phone. Get this uri and send this to your server for later use. Here's the sample code. As in am working with angularjs so the code is in the format of anguarjs.

.factory('MPNS', function ($window){ var storage = window.localStorage;

function registerMPNS(){
    var pushNotification;
    pushNotification = window.plugins.pushNotification;
    pushNotification.register(
    channelHandler,
    errorHandler,
    {
        "channelName": "xyz", //channelName is whateveryou like
        "ecb": "onNotificationWP8",
        "uccb": "channelHandler",
        "errcb": "jsonErrorHandler"
    });
}

$window.onNotificationWP8 = function(e){

}

function channelHandler(event){
    var uri = event.uri;

//This is the uri you need for push notification }

function errorHandler(e){
}

function successHandler(e) {
}
return{
    register: function(){
        return registerMPNS();
    }       
};

});

sometimes MPNS does reply empty uri. so check wheather you get uri or not while your app starts.

gustter commented 10 years ago

Hi joshilomas.

For testing purposes, do I need to install from the store? Or is there a mechanism for linking the app installed via USB with the Client secret, etc?

Thanks!

fabiofapeli commented 9 years ago

Hello joshilomas,

My uri is always empty. I don't get fix the problem with a your example using angularjs.Your application is still working? Are you could send the html code complete?

gustter commented 9 years ago

fabiofapeli, you have to ask for the uri several times. yes, so strange, but Microsoft is Microsoft :)

revaret commented 9 years ago

@joshilomas your code is clean , can you write a blog about it so that everyone can see when they google it instead of coming here :)

tetreault commented 8 years ago

Over a year later and Cordova & WP8 still has garbage information on doing this (or really anything) for the Windows Phone. I am now in the same boat as you all.

kundan1988 commented 8 years ago

Anyone please help me out for Integrating Push Notification in Windows Phone Cordova.

mohammadmanzoor8972 commented 7 years ago

For me its working fine.

just keep loop RegisterMPNS Function until unless you are not getting uri.

function registerMPNS(){ var pushNotification; pushNotification = window.plugins.pushNotification; pushNotification.register( channelHandler, errorHandler, { "channelName": "xyz", //channelName is whateveryou like "ecb": "onNotificationWP8", "uccb": "channelHandler", "errcb": "jsonErrorHandler" }); }

$window.onNotificationWP8 = function(e){

}

function channelHandler(event){ var uri = event.uri; if(uri==''){ registerMPNS(); } }