0

I'm working on an SDK that uses FCM Topics. Whenever the Instance ID Token is refreshed, I subscribe again to every topic that user has previously subscribed to (I tested and saw that the Firebase SDK doesn't manage the subscriptions updates by itself, please correct me if I'm wrong).

The issue is that if I don't put a `Thread.sleep()` between each call to the Firebase Messaging Instance, the topic subscription fails.

Has anyone tried to do something similar and got different results? To clarify, I know about using an end point to register the new token via Google Instance ID and not looking to use it for now.
I'm using the Firebase 11.8.0 SDK.

public void refreshTopicsRegistrations() {
    Set<String> registeredTopics = topicsPreferences.getAll().keySet();
    new Thread(() -> {
        try {
            for (String topic : registeredTopics) {
                FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
                Thread.sleep(1500);
                FirebaseMessaging.getInstance().subscribeToTopic(topic);
                Thread.sleep(1500);
            }
        } catch (InterruptedException e) {
            Log.d("topic-refresh", e.getMessage());
        }
    }).start();
}
  • Please edit the question to show the actual failure message in its entirety. – Doug Stevenson Mar 07 '18 at 16:40
  • 1
    Possible duplicate of [How to restore topic subscriptions after refreshed token?](https://stackoverflow.com/questions/43553308/how-to-restore-topic-subscriptions-after-refreshed-token) – AL. Mar 07 '18 at 16:43
  • @DougStevenson there's no error, simply no push message reaches the app via topics, even after restarting the app. Token still works however – NoyG_Optimove Mar 07 '18 at 17:50
  • @AL. unfortunately, no – NoyG_Optimove Mar 07 '18 at 17:51
  • Then you're experiencing an unexpected behavior. I suggest reaching out to Firebase support to further debug the issue. Make sure to provide all the details, specially the registration token(s) that is affected. – AL. Mar 07 '18 at 17:53
  • Please file a bug report with as many details as possible that helps someone else reproduce the problem. https://firebase.google.com/support/contact/bugs-features/ – Doug Stevenson Mar 07 '18 at 17:56
  • Will do. Thanks guys for your quick help! – NoyG_Optimove Mar 07 '18 at 18:19

0 Answers0