简体   繁体   English

“休眠”应用会收到来自 FCM 的推送通知吗?

[英]Will 'Sleeping' apps receive push notifications from FCM?

I've been reading about non-standard app killing on https://dontkillmyapp.com/ .我一直在https://dontkillmyapp.com/上阅读有关非标准应用程序终止的信息。 In particular, I'm worried about how manufacturers are implementing mechanisms under the name of 'battery optimisations' which cripple the local notification API, by cancelling all alarms scheduled by an app after some time of inactivity: AlarmManager not working in several devices特别是,我担心制造商如何以“电池优化”的名义实施机制,通过在一段时间不活动后取消应用程序安排的所有警报来削弱本地通知 API: AlarmManager not working in several devices

Since there is no fix we as developers can implement to make local notifications work reliably, I'm wondering if I can just switch to push notifications.由于我们作为开发人员无法实施使本地通知可靠地工作的修复程序,我想知道我是否可以切换到推送通知。 But I'm also not sure whether I can rely on push notifications, as there seems to be conflicting information:但我也不确定我是否可以依赖推送通知,因为似乎有相互矛盾的信息:

Signal seem to say that their push notifications may be unreliable when battery optimisations are at work, though it's not clear whether this only applies to their custom web-socket push notification system, which it apparently uses when FCM isn't available: https://support.signal.org/hc/en-us/articles/360007318711-Troubleshooting-Notifications#android_notifications_troubleshooting_phone Signal 似乎说,当电池优化工作时,他们的推送通知可能不可靠,尽管尚不清楚这是否仅适用于他们的自定义网络套接字推送通知系统,它显然在 FCM 不可用时使用: https:/ /support.signal.org/hc/en-us/articles/360007318711-Troubleshooting-Notifications#android_notifications_troubleshooting_phone

It seems that push notifications which are sent via Firebase Cloud Messaging (FCM) will actually be received by the Google Play Services, so is it possible they may be received even if your app has been 'battery optimised'?似乎通过 Firebase Cloud Messaging (FCM) 发送的推送通知实际上会被 Google Play 服务接收,那么即使您的应用程序已“电池优化”,它们是否也可能被接收?

Can anyone shed some light on this?任何人都可以阐明这一点吗? Can push notifications via FCM be more reliable than local notifications, when working around non-standard app killing?在处理非标准应用程序终止时,通过 FCM 推送通知是否比本地通知更可靠?

Push notifications will work but still they will be affected by battery optimizations.推送通知会起作用,但它们仍然会受到电池优化的影响。 Things like Doze mode will make your app poll-rate depend on things like user's usage of the phone;诸如打瞌睡模式之类的东西将使您的应用程序轮询率取决于用户对手机的使用情况; battery-level and etc.电池电量等

There are things that we just cannot fight as developers and if the underlying OS decides that your app won't wake up it's better that the user gets a better phone...作为开发人员,有些事情我们无法抗拒,如果底层操作系统决定您的应用程序不会唤醒,那么用户最好获得更好的手机......

Apparently using FCM is no guarantee that notifications will be received - they may still fail to show due to non-standard battery optimisations.显然,使用 FCM 并不能保证一定会收到通知——由于非标准电池优化,它们可能仍然无法显示。

This is documented by the following article:以下文章记录了这一点:

https://hackernoon.com/notifications-in-android-are-horribly-broken-b8dbec63f48a https://hackernoon.com/notifications-in-android-are-horribly-broken-b8dbec63f48a

Which states that:其中指出:

Google GCM said that the notification was sent but there was no trace of the notification in the app's logs, it was as if the OS was swallowing notifications谷歌 GCM 表示已发送通知,但在应用程序日志中没有通知的踪迹,就好像操作系统正在吞下通知一样

After disabling battery optimisations, the notifications apparently worked again.禁用电池优化后,通知显然再次起作用。 Their workaround to this issue was:他们解决这个问题的方法是:

GCM delivery receipts essentially tell you whether the device received the push notification or not. GCM 交付收据实质上告诉您设备是否收到推送通知。 We coupled this with duplicate notification delivery receipts from inside of the app.我们将其与来自应用程序内部的重复通知送达收据相结合。 So any device where we got ack's from GCM but not from the device, was potentially missing pushes.因此,我们从 GCM 而不是从设备获得 ack 的任何设备都可能缺少推送。 Once the devices were identified, we started sending them bot messages on how to add flock in their device's auto-start list.一旦设备被识别,我们就开始向他们发送机器人消息,告诉他们如何将 flock 添加到他们设备的自动启动列表中。

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

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