How to get all device tokens from Firebase?

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

I am making a mobile application using firebase and its server using node.js.

I want to send a message push notificationfrom the server, but I do not know how to get the device token.

  • How to get device tokens from an external server? Now I am using the Firebase admin SDK.

  • Is the device token only generated when the application connects to the fcm server?

  • Do I have to save the token to another database when I first run the application and register the FCM server?

+4
source share
2 answers

1. ? SDK Firebase admin.

API . () , .

2. FCM?

(. )

FCM SDK .

FCM. FirebaseInstanceID ( SDK), , , .

3. , FCM-?

# 1, , , .

+4

, ,

public class MyAndroidFirebaseInstanceIdService extends FirebaseInstanceIdService {

    private static final String TAG = "MyAndroidFCMIIDService";

    @Override
    public void onTokenRefresh() {
        //Get hold of the registration token
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        //Log the token
        Log.d(TAG, "Refreshed token: " + refreshedToken);
    }
    private void sendRegistrationToServer(String token) {
        //Implement this method if you want to store the token on your server
    }
}

. Tutorial

+3

Source: https://habr.com/ru/post/1673372/


All Articles