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();
}