How to know wether we have already subscriped to a topic in Firebase Cloud Messaging?
Asked
Active
Viewed 4,958 times
6
-
2use `SharePreferences`. – rusted brain Jun 17 '16 at 11:47
-
I would too recommend sharedPref. There is an onComplete Listener that returns Successful if the subscription is done. I would save that to SharedPreferences. Or still if its that important to the Users Node in FirebaseRealTimeDb. Simplest way to check from he Clients side – Yo Apps Jul 06 '19 at 07:27
1 Answers
3
You can get token
String token = FirebaseInstanceID.getToken();
Log.d(TAG,token);
and do a Get to https://iid.googleapis.com/iid/info/token
If using curl
curl -X Get -H"Authorization:key=serverAPIkey" "https://iid.googleapis.com/iid/info/token?details=true"
to see all of the device's subscribed topics
Find out details about a client app instance's subscriptions, including each topic name and subscribe date. See get information about app instances

Skyler
- 97
- 3
-
2Skyler is correct, but there is no way to do this from the client side. Note however that subscribing multiple times is not harmful. So when you should be able to subscribe/unsubscribe when you want to. – Arthur Thompson Jun 18 '16 at 16:13
-