Hey!
I have an issue with the plugin. When I am in the app, and I send notification with Parse, I receive an alert with the message (this works as intended). However, when app is in the background, nothing displays on the phone. Here is how I use plugin, and how I handle notifications:
var gmcId = "xxxxxxx";
var androidConfig = {
senderID: gmcId
};
document.addEventListener("deviceready", function(){
$cordovaPush.register(androidConfig).then(function(result) {
console.log("result: " + result);
}, function(err) {
// Error
})
$rootScope.$on('$cordovaPush:notificationReceived', function(event, e) {
switch( e.event )
{
case 'registered':
if ( e.regid.length > 0 )
{
// Your GCM push server needs to know the regID before it can push to this device
// here is where you might want to send it the regID for later use.
console.log("regID = " + e.regid);
}
break;
case 'message':
// if this flag is set, this notification happened while we were in the foreground.
// you might want to play a sound to get the user's attention, throw up a dialog, etc.
if ( e.foreground )
{
// if the notification contains a soundname, play it.
navigator.notification.beep(1);
alert(e.payload.data.alert)
}
else
{ // otherwise we were launched because the user touched a notification in the notification tray.
if ( e.coldstart )
{
}
else
{
navigator.notification.beep(1);
alert(e.payload.data.alert)
}
}
break;
case 'error':
$("#app-status-ul").append('<li>ERROR -> MSG:' + e.msg + '</li>');
break;
default:
$("#app-status-ul").append('<li>EVENT -> Unknown, an event was received and we do not know what it is</li>');
break;
}
});
}, false);
Thanks!!
Btw, this is the structure of the Parse notification that I receive:
Hey! I have an issue with the plugin. When I am in the app, and I send notification with Parse, I receive an alert with the message (this works as intended). However, when app is in the background, nothing displays on the phone. Here is how I use plugin, and how I handle notifications:
Thanks!!
Btw, this is the structure of the Parse notification that I receive:
{"collapse_key":"do_not_collapse", "event":"message", "foreground":true, "from":"xxxxxxxxxx", "payload":{ "data": {"alert":"asdasdas","push_hash":"bff149a0b87f5b0e00d9dd364e9ddaa0"},"push_id":"2iFhVp2R4u","time":"2015-07-21T12:24:09.905Z"}}