Hi All,

Kindly assist, i cannot register a device as the error is

04-19 07:15:08.179: D/CordovaLog(2454): ["failed to register ",null]

My initPushwoosh function is as follows:

function initPushwoosh() { var pushNotification = window.plugins.pushNotification;

pushNotification.registerDevice({ projectid: "mygoogleprojectid", appid : "pushwooshappid" },
    function(status) {
        var pushToken = status;
        console.warn('push token: ' + pushToken);
    },
    function(status) {
        console.warn(JSON.stringify(['failed to register ', status]));
    }
);

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));
    }

    navigator.notification.alert(title);
});

}

Could there be something im missing or need to be added? Also when i change to:

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_NUMBER", pw_appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
pushNotification.onDeviceReady({ projectid: "GOOGLE_PROJECT_NUMBER", pw_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]));
    }
);

}

I get:

04-19 07:58:49.535: W/System.err(3105): org.json.JSONException: Index 0 out of range [0..0) 04-19 07:58:49.551: W/System.err(3105): at org.json.JSONArray.get(JSONArray.java:263) 04-19 07:58:49.551: W/System.err(3105): at org.json.JSONArray.getJSONObject(JSONArray.java:480) 04-19 07:58:49.555: W/System.err(3105): at com.pushwoosh.plugin.pushnotifications.PushNotifications.initialize(PushNotifications.java:153) 04-19 07:58:49.575: W/System.err(3105): at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:364) 04-19 07:58:49.575: W/System.err(3105): at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:66) 04-19 07:58:49.579: W/System.err(3105): at org.apache.cordova.api.PluginManager.exec(PluginManager.java:224) 04-19 07:58:49.579: W/System.err(3105): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:51) 04-19 07:58:49.583: W/System.err(3105): at android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)

Then java.lang.NullPointerException follows after this. Kindly assist. I have been having this problem for the last three weeks :(.

Kind Regards, Peter

asked 19 Apr '15, 08:56
Vitalz's gravatar image

Vitalz
113

edited 20 Apr '15, 12:34

Be the first one to answer this question!
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:

×446
×326
×190
×165

question asked: 19 Apr '15, 08:56

question was seen: 1,004 times

last updated: 20 Apr '15, 12:34