public class MyFirebaseInstanceService extends FirebaseMessagingService
{
@Override
public void onNewToken(String s) {
super.onNewToken(s);
Log.d("DTAG","onNewToken: "+s);
}
}
在MainClass中:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( MainActivity.this, new OnSuccessListener<InstanceIdResult>() {
@Override
public void onSuccess(InstanceIdResult instanceIdResult) {
String newToken = instanceIdResult.getToken();
Log.d("DTAG","Token Main: "+newToken);
}
});
}
第一次运行我的应用时,我得到的输出是:
D/DTAG: Token Main: token_a
D/DTAG: onNewToken: token_b
我得到的秒时间:
D/DTAG: Token Main: token_a
请帮助我得到这个...
1. If I run for the first time, from where is gets token in MainClass (token_a)
2. In case the token is renewed (onNewToken) which is token_b, why I still keep seeing token_a when launching the app in second time and what happened to token_b?