VSB VSB - 1 year ago 125
Android Question

Android Firebase Cloud Messaging(FCM): Will subscribeToTopic do automatic retries?

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


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?

Answer Source


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download