Pushnotifications with Pushwoosh

Hey there,

I’m developing an app for a conference and we want to implement pushnotifications. I just registered me for the service Pushwoosh and set the GCM up and also the pushwoosh app itself.

I think i just implemented it wrong in my app.

I did the steps from here: https://www.pushwoosh.com/programming-push-notification/android/android-additional-platforms/phonegapcordova-sdk-integration/

I put the first function in a extra file pushnotification.js

function initPushwoosh()
{
    var pushNotification = window.plugins.pushNotification;
 
    //set push notifications handler
    document.addEventListener('push-notification', function(event) {
        var title = event.notification.title;
        var userData = event.notification.userdata;
                                 
        if(typeof(userData) != "undefined") {
            console.warn('user data: ' + JSON.stringify(userData));
        }
                                     
        alert(title);
    });
 
    //initialize Pushwoosh with projectid: "GOOGLE_PROJECT_ID", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
    pushNotification.onDeviceReady({ projectid: "GOOGLE_PROJECT_ID", appid : "PUSHWOOSH_APP_ID" });
 
    //register for pushes
    pushNotification.registerDevice(
        function(status) {
            var pushToken = status;
            console.warn('push token: ' + pushToken);
        },
        function(status) {
            console.warn(JSON.stringify(['failed to register ', status]));
        }
    );
} 

and in the

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {...

i put this

    document.addEventListener("deviceready", initPushwoosh, true);

if i now want to send a test notification nothing happens. What did I wrong implementing this?
(of course i did all the other steps from that guide!)

Best regards,

Luc

If it’s not too late, PushWoosh has different plugins for local builds with Cordova v. PhoneGap Build. Their APIs are a little different (pay close attention to minor differences! your example would work for Cordova, but NOT PGB), and you have to configure PushWoosh differently for using PGB (select Apppresser under Application–>config.). Additionally, you must include the PushNotification.js with PGB.

Hope that helps! Now if I can get my damn app registering…