3

hello everyone this issue is driving me crazy im trying to apply pushwoosh sdk for for phonegap and it just cant seem to work! i have checked evrything from my provisioning profile that has "aps-envierment" in at, all the push certificate are configured. p12 aps development everything, but the device just dosnt register! sample code to my index.html

i have the plugin configured in the config.xml all the plugin folder with the .h .m of the pushwoosh are inside the plugin folder and everything compiling alright, just not getting the register prompt when running, if any one can help will be much much appreciated.

 <script type="text/javascript" charset="utf-8" src="PushNotification.js"></script>


    <script type="text/javascript" src="cordova.js"></script>

    <script type="text/javascript">


        function initPushwoosh()
        {

             alert('initing pushwoosh');
            var pushNotification = window.plugins.pushNotification;
            pushNotification.onDeviceReady();

            pushNotification.registerDevice({alert:true, badge:true, sound:true, pw_appid:"*****the right id just hidden", appname:"testingNewPush"},
                                            function(status) {
                                            var deviceToken = status['deviceToken'];
                                            console.warn('registerDevice: ' + deviceToken);
                                            },
                                            function(status) {
                                            console.warn('failed to register : ' + JSON.stringify(status));
                                            //navigator.notification.alert(JSON.stringify(['failed to register ', status]));
                                            });

            pushNotification.setApplicationIconBadgeNumber(0);

            document.addEventListener('push-notification', function(event) {
                                      var notification = event.notification;
                                    navigator.notification.alert(notification.aps.alert);
                                      pushNotification.setApplicationIconBadgeNumber(0);
                                      });
        }




        function onBodyLoad()
        {

            document.addEventListener("deviceready", onDeviceReady, false);

        }



        function onDeviceReady(){


            alert('device');
            initPushwoosh();


            app.receivedEvent('deviceready');
        }





        </script>


    <title>Hello World</title>
</head>
<body onload="onBodyLoad()">
    <div class="app">
        <h1>Apache Cordova</h1>
        <div id="deviceready" class="blink">
            <p class="event listening">Connecting to Device</p>
            <p class="event received">Device is Ready</p>
        </div>
    </div>

</body>

1 Answer 1

1

Do you see the alert: alert('initing pushwoosh')?

If you don't get the "allow push notifications" popup please double check that the provisioning profile you are using has "aps-environment" string in it. However SDK should give you a warning if you try running with non-push enabled profile.

So far the code looks good to me, some logs from console might really help.

P.S. As far as I know Pushwoosh can do a quick review of the integration code for Premium accounts. But you have to contact their support to confirm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.