android - IBM Worklight 5.0.6.1 - Not getting Push Notifications when phone/app is closed -
i have worklight hybrid app basic push notification working in android. if app running , in focus when notification pushed, behaves expect. notification callback in app called, , pops simpledialog. all good.
if dismiss app clicking on home button, , new message arrives, see notification in android notification area, , when click on item in android notification list, item gets dismissed list (but app not come focus) if launch app apps menu, sitting left , simpledialog showing. (my notification handler called) mostly good, expected app come focus when selected notification in android notification list.
if dismiss app clicking on button, , new message arrives, see notification in android notification area, , when click on item in android notification list, item gets dismissed list (but app not come focus) if launch app apps menu, launches app fresh (i have log in again) , notification handler never called. not good.
if force stop app, or turn phone off while notification being sent (but leave subscription in place), notification never shows on phone. don't see in android notification area when restart phone, , notification handler in app never called when launch app. very bad.
is expected behavior?
i'm using worklight 5.0.6.1, , i've seen behavior on android emulator @ platform 4.2.2 , physical phone @ platform 4.1.2
edt: adding code.
the adapter:
wl.server.createeventsource({ name : "mypusheventsource", securitytest: "myapp-strong-mobile-securitytest" }); function submitnotification(userid) { var usersubscription = wl.server.getusernotificationsubscription( 'mypushnotification.mypusheventsource', userid); if (usersubscription == null) { return { result : "no subscription found user :: " + userid }; } var notification = wl.server .createdefaultnotification("there's work done!", 1, {}); wl.server.notifyalldevices(usersubscription, notification); return { result : "notification sent user :: " + userid }; }
and in app:
wl.client.push.onreadytosubscribe = function() { var pushsubscribe_success_callback = function(response) { wl.logger.debug("enter: pushsubscribe_success_callback"); }; var pushsubscribe_fail_callback = function(response) { wl.logger.debug("enter: pushsubscribe_fail_callback"); }; var pushnotificationreceived = function(props, payload) { wl.simpledialog.show("notification", props.alert, [ { text : "ok" }]); }; wl.client.push.registereventsourcecallback("mypush", "mypushnotification", "mypusheventsource", pushnotificationreceived); if (!wl.client.push.issubscribed("mypush")) { wl.client.push.subscribe("mypush", { onsuccess : pushsubscribe_success_callback, onfailure : pushsubscribe_fail_callback }); } };
as said, if app in focus, works without hitch, know have google messaging account , keys set correctly. reason i'm seeing unexpected results if app isn't in focus when notification published.
ok. took me long enough figure 1 out, in case follows, here problem:
i had renamed app opening [android project]/res/values/strings.xml , changing value of app_name.
that causes app not launch when push notification app selected.
i fixed changing app_name original value, , adding new string named app_label friendly name. went androidmanifest.xml, , changed 2 instances of android:label="@string/app_name" to: android:label="@string/app_label" , sha-zam! app had friendly name , clicking on notifications launched it.
for measure modified push_notification_title in strings.xml friendly name, , improved display of notification , did not break launching of app.
Comments
Post a Comment