简体   繁体   中英

Remote Push Notifications and terminated Apps

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM