Can we WLPush::subscribe()
without WLClient::connect()
?
Background
I'm working on an Android native application (offline version - App can work in case of no Internet) using the IBM Worklight framework, and I am implementing push notification. As I understand, we need WLPush::subscribe()
in order to get the notification. But we cannot directly invoke the subscribe() method, it has to be in the Callback OnReadyToSubscribeListener
. The listener will be invoked once connection is established.
The issue faced is:
- The app is registered to GCM
- The app was terminated
- A push notification is received in the device, I could already see the notification.
But I couldn't get the WLEventSourceListener
invoked... because I need to connect
before subscribe
! This doesn't make any sense for me - because we have already have the notification shown in client console(DDMS).
I know that I could probably:
- Override
GCMIntentService
- Force
WLClient::connect()
to trigger the TIMING
Can someone offer a better solution?
Updated on 31th October
I am using the "WL Android native push" sample project and found that it is impossible to get the callback WLEventSourceListener invoked without connect.
Steps to reproduce:
- Launch the sample client
- Click the "connect" to connect to server
- Connection returns successfully, click "subscribe" to subscribe
- In Eclipse IDE, right click the push adapter to send a push to client
- At client side, it receives the push message(shown on DDMS console log) and
WLEventSourceListener
is invoked. - Kill the App
- Resend the push
- Push message is shown in the DDMS console log, and a notification in the notification bar.
- App is launched when the notification is clicked.
- The
WLEventSourceListener
get invoked when connect button is clicked again.
Here is the question. In step 9, the push message reaches the client, but in step 10, connect
must be invoked to get WLEventSourceListener
invoked. Is there a way to get the message without connect?