Home » Android » android – Firebase Clouding Messaging : Call subscribeToTopic method multiple times

android – Firebase Clouding Messaging : Call subscribeToTopic method multiple times

Posted by: admin June 15, 2020 Leave a comment

Questions:

I’m using FCM for Topic Messaging on Android.

If I call the FirebaseMessaging.getInstance().subscribeToTopic("news") multiple times to subscribe ‘news’ topic, what will happen?

I spent my time searching for it but I couldn’t. I’m using that method in my MainActivity so It’s called every time when app is launched. In my experience It’s not problem to get push messages and I couldn’t find out any problems yet. But I wanna know it exactly when I call it multiple times.

How to&Answers:

You can only be subscribed to a topic once.

Additional calls to subscribeToTopic() for the same topic are essentially no-ops, they make no difference.