In my MainActivity
in my log, I can see the token using FirebaseInstanceId.getInstance().getToken()
and it display the generated token. But it seems like in my MyFirebaseInstanceIDService
where it is extends to FirebaseInstanceIdService
, the onTokenRefresh()
is not called, where in this function it was said that the token is initially generated here. I needed to call sendRegistrationToServer()
that's why I'm trying to know why it doesn't go in the onTokenRefresh()
.
Here is my code
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
sendRegistrationToServer(refreshedToken);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…