IBM Worklight 5.0.6.1 - Not getting Push Notifications when phone/app is closed

岁酱吖の 提交于 2019-11-28 10:36:06

OK. It took me long enough to figure this one out, so in case anyone follows, here is the problem:

I had renamed the app by opening [android project]/res/values/strings.xml and changing the value of app_name.

That causes the app to not launch when a push notification for the app is selected.

I fixed this by changing app_name back to its original value, and adding a new String named app_label for the friendly name. I then went into AndroidManifest.xml, and changed the 2 instances of android:label="@string/app_name" to: android:label="@string/app_label" And sha-zam! My app had a friendly name AND clicking on notifications launched it.

For good measure I modified push_notification_title in strings.xml to be the friendly name, and that improved the display of the notification and did not break the launching of the app.

All four scenarios work for me as expected.
Tested with Worklight v5.0.6.1 and the accompaning PushNotifications project.

After setting up the project with a GCM Key and GCM ID, deploying the adapter and application and launching the app on my Galaxy S4 running Android 4.2.2:

  1. I have logged-in, subscribed and sent a notification
  2. I have logged-in, subscribed, tapped the Home button to send the app to the background and sent a notification
  3. I have logged-in, suscribed, tapped the Back button to close the app and sent a notification
  4. I have logged-in, subscribed, closed the app, turned off the device

  1. While the app was in the foreground, the dialogs of the received notification were displayed
  2. While the app was in the background, I received the notification in the notification bar. Tapping it brought the app to the foreground and the dialogs of the received notification were displayed
  3. While the app was closed, I received the notification in the notification bar. Tapping it launched the app, after logging-in the dialogs of the received notification were displayed
  4. Turned on the device, waited for it to connect to the network, I received the notification in the notification bar. Tapping it it launched the app, after logging-in the dialogs of the received notification were displayed

If this is a push notifications app you have written yourself, I suggest that you review your code. You can use the sample app as guidance.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!