Android Firebase云消息传递(FCM):是否subscribeToTopic自动重试? [英] Android Firebase Cloud Messaging(FCM): Will subscribeToTopic do automatic retries?

查看:998
本文介绍了Android Firebase云消息传递(FCM):是否subscribeToTopic自动重试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了订阅android客户端中的主题,我们应该调用:

  FirebaseMessaging.getInstance()。subscribeToTopic(news ); 

我想知道在执行此指令时互联网连接不可用会发生什么?



当互联网连接可用或者我们的开发人员应该处理这种情况时,Google服务会自动重试以进行订阅吗?

解决方案:更新



因此,似乎有更多的subscribeToTopic,根据@ DiegoGiorgini的评论上一篇:


subscribeToTopic 会在后台继续重试,但是与您的应用程序生命周期(而不是谷歌服务)。所以,如果你的应用程序被杀死,它将停止重试,直到应用程序再次打开。 (这个动作是存储的,所以当应用程序重新启动的时候它会被恢复)

我之前尝试的方式是在给定期间,我会杀了应用程序,并没有再次拉起来。






所以我试着检查这个出来了。看起来,如果设备在发送订阅请求时处于离线状态,它会重新尝试一段时间(20-30秒左右?),如果还没有连接,则会停止。该请求可能已达到超时错误。但是由于 subscribeToTopic(),您无法通过您的客户端应用程序来确定这一点。如果需要,您可以发送功能请求,与此相关。然而,截至目前,我认为你可以做的一个方法是在你的客户端应用程序中有一个检查器,如果只有设备在线,你会发送请求。

你也可以通过你的应用服务器来检查它,就像我在以前的帖子


To Subscribe to a topic in an android client we should call:

FirebaseMessaging.getInstance().subscribeToTopic("news");

I want to know what happens if the internet connection is not available at moment that this instruction is executed?

Will google services automatically retry to do subscription when Internet connection become available or we developer should handle this case?

解决方案

Update:

So it seems there's more to subscribeToTopic, as per @DiegoGiorgini's comment in your previous post:

subscribeToTopic will keep retry on background, but it's tied to your app lifecycle (not to google services, yet). So if your app is killed it will stop retrying until the app is open again. (the action is stored so it will be resumed when the app is started again)

The way I was trying out before was after the given period, I will be killing the app and didn't pull it up again.


So I've tried checking this out. It seems that if the device is offline when the request for subscription is sent, it will re-try for a period of time (20-30 seconds or so?) then will stop if still not connected. The request probably reached a time-out error. But since there is no return value for subscribeToTopic(), there is no way for you to determine this via your client app. You can send in a Feature Request if you want, pertaining to this.

However, as of the moment, an approach I think that you could do is to have a checker in your client app, where if only the device is online will you send the request.

You can also check it via your app server as I've mentioned in your previous post.

这篇关于Android Firebase云消息传递(FCM):是否subscribeToTopic自动重试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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