I am using FCM in my project. This is done by following documentation. It works nice on android version 4.4 and above. But I get the null value using FirebaseInstanceId.getInstance().getToken()
after installing and clearing data on Nexus 7 with android version 4.3. It seems like onTokenRefresh()
is not called and token is not generated. That's why I'm asking this question. I also check for Google Play services to ensure it has the updated version by this method.
public static boolean checkGooglePlayService(Activity context) {
final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(context);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(context, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST).show();
}
return false;
}
return true;
}