How to get all of device tokens from Firebase?

后端 未结 4 675
鱼传尺愫
鱼传尺愫 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:48

    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

    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
        }
    }
    

    See the following Tutorial

提交回复
热议问题