A
A
Alexey So2016-08-11 11:21:34
Android
Alexey So, 2016-08-11 11:21:34

How to simulate or trigger a token change?

I am using firebase notification.
I would like to test sending a token when it is changed.
I am using standard code.
How can you call onTokenRefresh?
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
public Handler mHandler;
/**
* Called if InstanceID token is updated. This may occur if the security of
* the previous token had been compromised. Note that this is called when the InstanceID token
* is initially generated so this is where you would retrieve the token.
*/
// [START refresh_token]
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
// TODO: Implement this method to send any registration to your app's servers.
try {
sendRegistrationToServer(refreshedToken);
}catch (Exception e){
Lo.d("sendRegistrationToServer Exception:"+e.toString());
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Perelygin, 2016-08-16
@mayhembr

Weird question. in the docs on onTokenRefresh() it is written that the method will be called in these cases:
App deletes Instance ID
App is restored on a new device
User uninstalls/reinstall the app
User clears app data
write logs like, what's the problem, I don't understand?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question