How to handle FirebaseInstanceId.getInstance().getToken() = null

前端 未结 7 2133
情书的邮戳
情书的邮戳 2020-12-05 15:43

I have just migrated to FCM. I have added my class that extends from FirebaseInstanceIdService to receive a refreshedToken as and when appropriate.

My question is sp

7条回答
  •  無奈伤痛
    2020-12-05 15:52

    Use this class extends with..

    public class MyFirebaseInstanceIDService  extends FirebaseInstanceIdService {
    
        private static final String TAG = "MyFirebaseIIDService";
        public static final String REGISTRATION_SUCCESS = "RegistrationSuccess";
    
    
        @Override
        public void onTokenRefresh() {
            String refreshedToken = FirebaseInstanceId.getInstance().getToken();
            Log.d(TAG, "Refreshed token: " + refreshedToken);
    
            Toast.makeText(MyFirebaseInstanceIDService.this,refreshedToken,Toast.LENGTH_LONG).show();
        }
    }
    

提交回复
热议问题