Hi, my old code don't work with new pushwoosh version, what i need to change?:

if (device.platform == 'android' || device.platform == 'Android')
        {
            pushNotification = window.plugins.pushNotification;

            // Handle notifications
            document.addEventListener('push-notification', function(event)
            {
                var title = event.notification.title;
                var message = event.notification.message;
                if(title.length > 0)
                {
                    if(title && title != "null")
                    {
                        navigator.notification.alert(title, successHandler, "Notification", "OK");
                    }
                }
                else if(message.length > 0)
                {
                    if(message && message != "null")
                    {
                        navigator.notification.alert(message, successHandler, "Notification", "OK");
                    }
                }
            });

            // Register device
            pushNotification.registerDevice(
            {
                alert: true,
                badge: true,
                sound: true, 
                projectid: push_pushwoosh_senderid,
                appid: push_pushwoosh_appid
            },
            function(status)
            {
                //var pushToken = status;
                //showStatusMsg('push token: ' + JSON.stringify(pushToken));

                // Custom Android Settings
                pushNotification.setMultiNotificationMode();    // Multi notifications
                pushNotification.setEnableLED(true);            // Blink led on push
                pushNotification.setSoundType(2);               // Play default sound on push
                pushNotification.setVibrateType(2);             // Vibrate on push
                // pushNotification.setLightScreenOnNotification(false); // Light screen on push
            },
            function(status)
            {
                //showStatusMsg(JSON.stringify(['failed to register', status]));
            });
        }
asked 29 Nov '14, 11:56
bongoz1981's gravatar image

bongoz1981
112

Hi,

Please check the guide:
https://www.pushwoosh.com/programming-push-notification/android/android-additional-platforms/phonegapcordova-sdk-integration/

Note that registerDevice now takes callback parameters only and configuration parameters has been moved to onDevice Ready

//initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
pushNotification.onDeviceReady({ projectid: "GOOGLE_PROJECT_NUMBER", 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]));
    }
);
permanent link
answered 01 Dec '14, 06:51
shader's gravatar image

shader
3.9k7

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×447
×326
×91

question asked: 29 Nov '14, 11:56

question was seen: 1,049 times

last updated: 01 Dec '14, 06:51