How to get all of device tokens from Firebase?

后端 未结 4 665
鱼传尺愫
鱼传尺愫 2020-12-20 15:03

How to get device tokens (FCM registration tokens) from Firebase?

I\'m making mobile app using firebase and its server using node.js.

I want to send

4条回答
  •  旧巷少年郎
    2020-12-20 15:51

    1. How to get device tokens from external server? I'm using Firebase admin SDK now.

    There is currently no API to retrieve all the Registration tokens for your app from the Server side. It's the developer's (you) responsibility to send and store the Registration token to your App Server, which is generated from the Client App side.

    2. Is the device token only generated when the app is connected FCM server?

    The documentation pretty much covered this (see also my answer here):

    On initial startup of your app, the FCM SDK generates a registration token for the client app instance.

    It doesn't technically get connected to the FCM Servers. It connects to the FirebaseInstanceID service (via the SDK), which in turn generates the Registration Token.

    3. Should I save token to another database when user first run the app and register FCM server?

    As I mentioned in #1, you should save it where you can easily access it to send a message.

提交回复
热议问题