Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push notification with the phonegap - cordova push plugin and pushwoosh.com

I have tested to send push notifications with cordova-1.8.1.js and the push plugin together with pushwoosh.com and it work as it should. I followed this tutorial: http://www.pushwoosh.com/programming-push-notification/push-notification-sdk-integration-for-phonegap/

The push notification is send to my iPhone and it plays the sound and shows the notification when the phone and app is closed, good! But if I open the phone when the notification is visible then the app is opened as it should...but the alert that is displayed is saying: Alert "push-notification","{\aps\":\sound\":\"default\",\"alert\":\" and then the message....\"}}”

  1. So what is wrong, it should only write the message in the alert and not the rest?

Also if I delete the app with home button and start it again I get another alert saying "registerDevice", "type":"7".....and so on. 2. How can I make this go away?

Any input appeciated, thanks!

like image 230
Claes Gustavsson Avatar asked Jun 28 '12 09:06

Claes Gustavsson


1 Answers

Problem solved. Use this and it will only show the message in the alert and nothing else.

document.addEventListener('push-notification', function(event) {
    //console.warn('push-notification!: ' + event.notification);
    //navigator.notification.alert(JSON.stringify(['push-notification1!', event.notification]));
    var notification = JSON.parse(event.notification);
    navigator.notification.alert(notification.aps.alert);
    //pushNotification.setApplicationIconBadgeNumber(0);
    pushNotification.setApplicationIconBadgeNumber(0);
    });
like image 67
Claes Gustavsson Avatar answered Nov 11 '22 19:11

Claes Gustavsson