简体   繁体   English

远程推送通知和终止的应用程序

[英]Remote Push Notifications and terminated Apps

My question is about standard remote push notifications on iOS and Android devices when the app is terminated. 我的问题是有关终止该应用程序时iOS和Android设备上的标准远程推送通知的信息。

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. 对于前景,背景和暂停模式,它很明显,并且在iOS和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. 但是,当该应用终止时,iOS和Android的远程通知似乎存在本质区别。

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. 对于iOS:如果该应用已终止(未挂起),则iOS系统会收到标准的远程通知,并将其显示在通知中心。 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. 对于Android:应用终止后,通知中心不会显示标准的远程推送通知。 (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 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 ). 但是,也有讨论表明即使应用程序已终止( 在应用程序关闭时未收到Android推送通知) ,远程推送仍始终显示在系统托盘中。 That would be the same behavior as for iOS. 这与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? 切入要点:即使应用程序已终止/强制退出/未运行,Android上是否也可以将远程推送通知发送到设备的系统托盘?

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. 我现在可以回答我自己的问题:可以在应用未运行时将推送通知发送到Android设备(在通知中心)。

The issue with notifications not being delivered was caused by Huawei's EMUI and specific battery saving settings. 无法发送通知的问题是由华为的EMUI和特定的省电设置引起的。 On Huawei P8, P9 and probably many other devices with EMUI the apps are not allowed to receive notifications when not running. 在华为P8,P9以及可能带有EMUI的许多其他设备上,当应用程序不运行时,它们不会收到通知。 They must be authorized explicitly in the battery saving settings. 必须在节电设置中明确授权它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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