3

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.

Community
  • 1
  • 1
ghost rider3
  • 448
  • 1
  • 5
  • 17
  • 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 Dec 31 '13 at 15:17
  • 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 `subscribe`button still **disabled** I think the `onReadyToSubscribe` is not invoked. that's why the user cannot subscribe. – ghost rider3 Dec 31 '13 at 15:43

1 Answers1

2

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");
}
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • As you recommended, I did an investigation with **Wireshark** and I noticed that the `JSESSIONID`is not updated, also I tried your code by adding `WL.Client.connect' but didn't work also. What did you mean by **This should not be done in a production environment** ? – ghost rider3 Jan 02 '14 at 09:17
  • That my code above is not a solution (it worked for me...); Anyway, jut wait until I update my answer soon... – Idan Adar Jan 02 '14 at 09:30
  • @ghostrider3, see my edited answer above. Please tell me: are you an IBM customer or business partner? – Idan Adar Jan 02 '14 at 13:40
  • Thank you @Idan, I'm a business partner – ghost rider3 Jan 02 '14 at 14:12
  • @ghostrider3, what is the name of your company? Who is customer? Is it an IBM customer? – Idan Adar Jan 05 '14 at 17:03
  • @ghostrider3. This has been fixed for the next version of Worklight. If you have a customer application that requires this fix, open a PMR and it will be back-ported to the Worklight version you are using. – Idan Adar Feb 06 '14 at 15:11
  • Thanks Idan, I wasn't able to open a PMR But I reported it for the concerned party and it will do the whole stuff. – ghost rider3 Feb 07 '14 at 09:33
  • Make sure they mention this question. – Idan Adar Feb 07 '14 at 11:22