Skip to content Skip to sidebar Skip to footer

Android Firebase Cloud Messaging(fcm): Will Subscribetotopic Do Automatic Retries?

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 no

Solution 1:

Update:

subscribeToTopic() now returns a Task<Void> so you could attach an OnCompleteListener() to check if it is successful or not.


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.

Post a Comment for "Android Firebase Cloud Messaging(fcm): Will Subscribetotopic Do Automatic Retries?"