Pergunta

I have been trying to implement pushwoosh into my javascript based application with phonegap( for Android ).

I have gone through their tuturials and example, and I am also able to register the device to GCM server for getting notifications. But somehow I am not getting the callback on registering the device.

Code goes here :

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

//projectid: "581719621125", appid : " EB8C9-89549"
pushNotification.registerDevice({
    projectid: CONFIG.projectID, 
    appid : CONFIG.appId
},
function(token) {
    console.warn('Push token onPushwooshInitialized : ' + pushToken);
    onPushwooshInitialized(token);
},
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);

    pushNotification.stopGeoPushes();
});

}

As you can see the first function that registerDevice takes is for success callbacks and the other one is for failure/erros.

What I see in eclipse Log Cat ( Console ) is it shows something like this

03-19 10:23:35.339: V/GCMRegistrar(548): Is registered on server: true
03-19 10:23:35.369: W/dalvikvm(548): Exception Ljava/lang/RuntimeException; thrown during Landroid/os/AsyncTask;.
03-19 10:23:35.399: W/PushWoosh DeviceFeature2_5(548): Try To sent AppOpen
03-19 10:23:36.669: I/global(548): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
03-19 10:23:36.669: W/PushWoosh: NetworkUtils(548): PushWooshResult: {"status_code":200,"status_message":"OK","response":null}
03-19 10:23:36.679: W/PushWoosh DeviceFeature2_5(548): Send AppOpen success
03-19 10:23:36.749: I/dalvikvm(548): Rejecting re-init on previously-failed class Lcom/arellomobile/android/push/utils/WorkerTask; v=0x0
03-19 10:23:36.749: W/DeviceRegistrar(548): Try To Registered for pushes
03-19 10:23:37.569: I/global(548): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
03-19 10:23:37.580: W/PushWoosh: NetworkUtils(548): PushWooshResult: {"status_code":200,"status_message":"OK","response":null}
03-19 10:23:37.590: V/GCMRegistrar(548): Setting registered on server status as: true
03-19 10:23:38.039: W/PushEventsTransmitter(548): No android.permission.BROADCAST_STICKY. Reverting to simple broadcast
03-19 10:23:38.120: W/DeviceRegistrar(548): Registered for pushes: APA91bFK0pv-d1gorQOs2lY_CJMYlNCkoLPWlHsO7oZyLa4gLzQqHnKGKW0mUyiW-llXpoWGpPpLPJAm1vY-Bxi_jnG462NIg2r7gvszqJBQt3wY69WsKnhq-_dgsqXRJ_m_KhoP4uS-2k7FM68LEs3cnCLZqjXHiA

As you can see, the last line says that the device is succesfully registered and there is the Token/Registration Id obtained from the server, but as it doesnot call my call back function, I am not able to handle the things. U have Googled and did not find the solution, I am not sure if their is any logical issue in this code from my side. Any useful link and support is much appreciated.

Foi útil?

Solução

Please get a new Pushwoosh.jar from: https://github.com/shaders/phonegap-cordova-push-notifications/tree/master/Android/lib

Or here: https://github.com/shaders/push-notifications-sdk/tree/master/SDK/Android

(they are the same)

The behaviour you see is due to this line: 03-19 10:23:38.039: W/PushEventsTransmitter(548): No android.permission.BROADCAST_STICKY. Reverting to simple broadcast

There are two ways to transmit registration to the app and this way (broadcast) is not supported by Phonegap Pushwoosh plugin yet. Somehow this change managed to get out...

Updating to the new Pushwoosh.jar should help. Please let me know how did it go.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top