2

My question is about standard remote push notifications on iOS and Android devices when the app is terminated.

In a nutshell:

There are different app states/modes:

  • Foreground
  • Background
  • Suspended
  • Terminated

There are different notification types:

  • Normal Notification (contains alert information)
  • Data/Silent Notification (contains data payload)
  • Mixed Notification (alert and data)

For foreground, background and suspended mode it is clear and does work very well on iOS and Android. Dependent on the notification type the expected behavior as stated in the docs.

But it seems there is an essential difference in remote notifications for iOS and Android when the app is terminated.

For iOS: If the app is terminated (not suspended) a standard remote notification is received by the iOS system and displayed in the notification center. There is no delegate called and the app is not put to background mode (not even if remote push background mode is enabled). When the user clicks the notification the app is started and the notification object is provided via the appropriate delegate. Summarized: The user can receive push notifications on his device even if the app was force-quitted.

For Android: When the app is terminated a standard remote push notification is not displayed in the notification center. (As soon the app is started and put to the background the notifications are received and displayed properly.

The documentation is very unclear because only foreground and background mode are mentioned. https://firebase.google.com/docs/cloud-messaging/concept-options https://firebase.google.com/docs/cloud-messaging/android/receive

There are many discussions that conclude that remote notifications are not displayed in the system tray (notification center) after the app as been force-quitted. But there is quite less discussion about the expected behavior after device restart and not starting the app.

But there are also discussions indicating that remote pushes are always displayed in the system tray, even if the app has been terminated (Android push notifications not being received when app closed). That would be the same behavior as for iOS.

To get to the point: Is it possible on Android to send remote push notification to the device's system tray, even if the app is terminated/force-quitted/not running?

jn-se
  • 238
  • 2
  • 9

1 Answers1

3

I can answer now my own question: It is possible to send push notifications to Android devices (in the notification center) while the app is not running.

The issue with notifications not being delivered was caused by Huawei's EMUI and specific battery saving settings. On Huawei P8, P9 and probably many other devices with EMUI the apps are not allowed to receive notifications when not running. They must be authorized explicitly in the battery saving settings.

jn-se
  • 238
  • 2
  • 9
  • I don't understand your answer, do you mean that if I force quit my android app (Settings -> Apps -> MyApp -> Force Stop) I can still receive push messages? Or maybe your phone was silently force quitting the app from background mode? – lelloman Aug 18 '17 at 10:13
  • As I know it does not make a difference if you quit the app or the system kills it. If it is quitted/terminated/not running the device receives push notifications on Google phones and many others. But in my case (force quitting the app manually) this behaviour was prohibited by the default battery saving settings of the Huawei P8. On Google phones it worked well in default settings. – jn-se Aug 18 '17 at 18:30
  • 1
    thanks for the reply, what I am experiencing is that if the app has been force stopped (from settings) no notification is shown. force stop is different from not-running, when force stopped the app is not supposed to do anything until the user actively launches it. do you confirm that you can see notifications even if the app is force stopped? – lelloman Aug 18 '17 at 19:03