远程推送通知和终止的应用程序 [英] Remote Push Notifications and terminated Apps

查看:64
本文介绍了远程推送通知和终止的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是关于应用终止时 iOS 和 Android 设备上的标准远程推送通知.

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

简而言之:

有不同的应用状态/模式:

There are different app states/modes:

  • 前景
  • 背景
  • 已暂停
  • 终止

有不同的通知类型:

  • 正常通知(包含警报信息)
  • 数据/静默通知(包含数据负载)
  • 混合通知(警报和数据)

对于前景、背景和暂停模式,它很清晰,并且在 iOS 和 Android 上运行良好.文档中所述的预期行为取决于通知类型.

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.

但在应用终止时,iOS 和 Android 的远程通知似乎存在本质区别.

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

对于 iOS:如果应用终止(未挂起),iOS 系统会收到标准远程通知并显示在通知中心.没有调用委托,并且应用程序不会进入后台模式(即使启用了远程推送后台模式也不会).当用户单击通知时,应用程序将启动并通过适当的委托提供通知对象.总结:即使应用被强制退出,用户也可以在其设备上接收推送通知.

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.

对于 Android:当应用终止时,通知中心不会显示标准的远程推送通知.(一旦应用程序启动并置于后台,就会收到并正确显示通知.

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.

文档很不清楚,因为只提到了前景和背景模式.https://firebase.google.com/docs/cloud-messaging/concept-选项https://firebase.google.com/docs/cloud-messaging/android/接收

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.

但也有讨论指出远程推送总是显示在系统托盘中,即使应用程序已终止(应用关闭时未收到 Android 推送通知).这与 iOS 的行为相同.

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.

切入正题:是否可以在 Android 上向设备的系统托盘发送远程推送通知,即使应用已终止/强制退出/未运行?

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.

>

未发送通知的问题是由华为的 EMUI 和特定的省电设置引起的.在华为 P8、P9 和许多其他带有 EMUI 的设备上,应用程序在未运行时不允许接收通知.他们必须在省电设置中明确授权.

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.

这篇关于远程推送通知和终止的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆