3
votes

I'm facing a subscription problem in a Worklight-based app with the Android environment.

The first time, when the application does the subscription, things are OK, but when unsubscribing and logging-out and then trying to login againand subscribe the user for the second time, things go wrong.

Normally, and as shown in the log, the notification is supported and the user is unsubscribed. However I get this error:

Can't subscribe, notification token is not updated on the server

This is the LogCat:

12-31 09:41:17.220: D/CordovaLog(6293): isSupported : true 12-31 09:41:17.220: D/CordovaLog(6293): isSubscribed : false 12-31 09:41:17.220: E/CPCapp(6293): Can't subscribe, notification token is not updated on the server 12-31 09:41:17.295: D/CPCapp(6293): Clearing notification subscriptions. 12-31 09:41:17.300: D/CPCapp(6293): Send new server notification token id. 12-31 09:41:17.300: D/GCMRegistrar(6293): resetting backoff for com.CPCapp 12-31 09:41:17.300: V/GCMRegistrar(6293): Registering app APP_PACKAGE of senders SENDER_NUMBER

I saw this question which may be related to the same issue but not sure it is: IBM Worklight 6.0 - Push subscribing stopped from working

I'm using Worklight 6.0, Android 4.1 and AdapterAuthentication with endUser as parameter.

1
Can you reproduce this same behavior using the sample push notifications project? login > subscribe > send push > unsubscribe > logout > login > subscribe. Does the second subscription attempt fail or succeed? - Idan Adar
I did the process with the sample push notification project and I putted this code in the logout function WL.Client.logout('PushAppRealm', {onSuccess: WL.Client.reloadApp}); after the seconde login, the subscribebutton still disabled I think the onReadyToSubscribe is not invoked. that's why the user cannot subscribe. - ghost rider3

1 Answers

2
votes

Based on the comments, I have also tested this with the push notifications sample project in Worklight 6.1.0.

The reason why the app is not able to subscribe/unsubscribe after logging out and logging back may be related to this CordovaPlugin message appearing in LogCat:

01-02 15:20:13.530: W/CordovaPlugin(27846): Attempted to send a second callback for ID: Push66817967 01-02 15:20:13.530: W/CordovaPlugin(27846): Result was: "APA91bHDrNHkbBwVtdrjqHj-KNGnmlMue2heoK7dGIHEnQW6ORJpaFregHRKs9qjUOsuIGue9r3ZfbQvwCQtgGZH9MI7U8gbXmrkrtYgyslHNlQemMjAxK40CuRO78Xw9sTnlrzvEFkA4oZ3PUYLgqMz2fnWsKLd0w"

I have opened a defect and it will be investigated.


There is one workaround that I have come up with and that worked for me, by doing the following, but do note:

  • This workaorund should be done only for the sake of minimal app flow testing until the problem is resolved.


HTML:

<input type="button" id="logoutButton" value="Logout" onclick="logoutFromApp();" />


JavaScript:
See the added WL.Client.connect after WL.Client.reloadApp.

function logoutFromApp() {
    WL.Client.logout("PushAppRealm", {
        onSuccess: function() {
            WL.Client.reloadApp(); 
            WL.Client.connect({onSuccess: successfulConnect, onFailure: failedConnect});
        },
        onFailure: function() { 
            alert ("Failed logging out");}
        }
    );
}

function successfulConnect() {
    WL.Logger.debug ("Connect state: success");
}

function failedConnect() {
    WL.Logger.debug ("Connect state: failure");
}