I am reading the documentation on this page under the heading "Retrieve the current registration token." I am confused by what it says.
The initial paragraph is very simple. It says we simply have to call...
FirebaseInstanceId.getInstance().getToken
That sounds very easy until I read the next paragraph that says I need to implement MyFirebaseInstanceIDService.java...
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService
{
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
}
So the first paragraph seems to say can make the call anyplace when I want to but the second paragraph has me wraping the call inside an onTokenRefresh().
So this begs the question WHEN does onTokenRefresh get called? With GCM I was able to choose WHEN I made the call asking for the token. With FCM it appears that we wait for onTokenRefresh to be called somewhere in time.