What do I use as the User Token to subscribe users to topics in Firebase?

后端 未结 1 1901
北荒
北荒 2021-01-16 15:50

I am sending a request to the firebase service to subscribe Firebase-authenticated users to topics:

POST https://iid.googleapis.com/iid/v1:batchAdd


        
相关标签:
1条回答
  • 2021-01-16 16:30

    No, FCM subscriptions are app instance based and not authenticated user based. When you use Firebase Cloud Messaging an Instance ID token is automatically generated for the device instance. That is the token that should be used to subscribe to topics.

    The usual flow would be that once the token is generated on the device and the user is signed in to your app, you associate those to values on your server, so on your server side when you want to subscribe a user to a topic you look up their corresponding Instance ID token and use that to subscribe them.

    See an Android sample of getting the IID token generation callback and sending it to the app server here. See similar iOS sample here.

    0 讨论(0)
提交回复
热议问题