6

How to know wether we have already subscriped to a topic in Firebase Cloud Messaging?

Xenolion
  • 12,035
  • 7
  • 33
  • 48
Manokar
  • 239
  • 3
  • 12
  • 2
    use `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 Answers1

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
  • 2
    Skyler 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
  • I can get a token even if i am subscribed to a different topic – Sagar Patil Dec 20 '16 at 06:58