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 push notification
message from server, but I don't know how to get devices token.
How to get device tokens from external server? I'm using Firebase admin SDK now.
Is the device token only generated when the app is connected fcm server?
Should I save token to another database when user first run the app and register FCM server?
The device token is generated when the app first connects, this token must then be stored in your database, and replaced if a new token is assigned
See the following Tutorial
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.
The documentation pretty much covered this (see also my answer here):
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.
As I mentioned in #1, you should save it where you can easily access it to send a message.