FCM - onTokenRefresh () is never called

I followed the setup process as directed for Firebase Cloud Messaging. But for some reason, onTokenRefresh is never called.

The following are the changes in this regard:

app build.gradle:

 dependencies { ... compile 'com.google.firebase:firebase-messaging:9.4.0' } apply plugin: 'com.google.gms.google-services' 

project build.gradle:

 dependencies { classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.google.gms:google-services:3.0.0' } 

AndroidManifest.xml

 <application ... <service android:name="com.blynq.app.services.MyFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT"/> </intent-filter> </service> <service android:name="com.blynq.app.services.MyFirebaseInstanceIDService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> </intent-filter> </service> </application> public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { @Override public void onTokenRefresh() { String token = FirebaseInstanceId.getInstance().getToken(); Log.i("FCM", "Token refreshed - " + token); registerTokenWithServer(token); } } 

Log state I/FirebaseInitProvider: FirebaseApp initialization successful , but onTokenRefresh () is not executed.

Of course, I missed something, but I could not understand where.

EDIT: In the case of emulators only, the Android device did a great job with the above settings.

+5
source share
1 answer

FCM clients require devices running Android 2.3 or higher, which also installs the Google Play Store app or runs the Android 2.3 emulator with the Google API.

+1
source

All Articles