On Phonegap build app - I get an alert with the push notification?

Comments

2 comments

  • Avatar
    synergywdeveloper

    I believe this is the correct functionality. If you wish to change the way the notification is displayed you can make changes to the following code.

    document.addEventListener('push-notification', function(event) {
        var title = event.notification.title;
        var userData = event.notification.userdata;
    
        console.warn('user data: ' + JSON.stringify(userData));
        alert(title);  // CHANGE THIS LINE OF CODE
    });
    

    It sounds like you wish to add the message to the DOM of your index.html page. You can do that using code like this:

    $("#parent_div").append("<p>"+title+"</p>");
    
  • Avatar
    Ghassan Safadi

    If using Phonegap Build:

    Add to Config.xml the Plugin:

    "org.apache.cordova.dialogs" version="0.2.6" />

    Update PushwooshiOS.js:

    document.addEventListener('push-notification', function(event) {

            //get the notification payload
            var notification = event.notification;
    
             //ADD the Dialogs Plugin Function
            navigator.notification.alert;
    
            //DISABLE the iOS Native Alert Function
                        //display alert to the user for example
            //alert(notification.aps.alert);
    
            //to view full push payload
            //alert(JSON.stringify(notification));
    
            //clear the app badge
            pushNotification.setApplicationIconBadgeNumber(0);
        }
    );
    

Please sign in to leave a comment.