android - FCM 上游消息传递的可靠性如何?

标签 android ios firebase google-cloud-messaging firebase-cloud-messaging

Firebase Cloud Messaging 的文档上游消息(从设备到服务器的消息)描述了如果设备离线,消息如何排队等待传送。

Android :

In cases where the device is offline or the FCM service is unavailable to forward upstream messages to your server, Android client app instances can accumulate a maximum of 20 pending messages.

iOS :

The FCM client library caches the message on the client app and sends it when the client has an active server connection.

但是如果应用程序在消息传递之前关闭了怎么办?一旦连接恢复,Firebase 是否会尝试使用任何类型的后台服务来传递此类消息?或者它们会排队等到应用程序下次打开,还是会被完全丢弃?

编辑:在我的实验中,至少有一个持久队列可以在应用重启时保存消息。但我仍然不确定(在每个操作系统上)什么情况会导致 Firebase 消息服务运行或不运行,尤其是当应用程序处于后台时。

最佳答案

在您提到的 iOS 部分,它明确指出:

The FCM client library caches the message on the client app and sends it when the client has an active server connection.

话虽如此,我认为 Android 也是如此。只要没有为客户端应用程序清除缓存,就可以安全地说数据仍然存在。但是,记住此 answer 中提到的内容也很好。通过@DanHulme:

Cached background processes

Don't forget that Android keeps background processes in memory even when they've stopped running, unless/until another process needs to use that memory. If the app is 'stopped', it's not using any resources, not even if Android is keeping it in memory.

所以我认为您最好在客户端应用程序中实现一个检查器,检查上游消息是否已成功发送,并在稍后重新发送(当连接已经建立时可用)如果没有。

关于android - FCM 上游消息传递的可靠性如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39581645/

相关文章:

java - 使用 Java 的简单 Android Studio TextView 代码

android - 在 phonegap 内调用和监控电话

java - 无法在 java 中从 String 转换为 float

ios - 如何在设备的前台应用程序中显示双高绿色状态栏(通话中)?

swift - 从 firebase 数据库中删除

android - 程序类型已存在:com.google.firebase.analytics.FirebaseAnalytics $ UserProperty

java - 使用 Maven 通过 Proguard 缩小 Akka

ios - ZXing Xamarin Forms iOS 白底(无Custom Renderer)

ios - 通过 Twilio 在 iOS 中使用后台进程

android - 如果 FirebaseDatabase.getInstance().goOnline() 在我的应用程序中多次调用,它是否会打开多个连接实例?