Reputation: 2032
I have followed the setup process as mentioned for Firebase Cloud Messaging. But somehow onTokenRefresh is never called.
Following are changes in this regard:
app's build.gradle:
dependencies {
...
compile 'com.google.firebase:firebase-messaging:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
project's 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);
}
}
Logs state I/FirebaseInitProvider: FirebaseApp initialization successful
, but but onTokenRefresh() is not executed.
I sure am missing something, but unable to understand where.
EDIT: Happening only with emulators, android device worked fine with the above settings.
Upvotes: 6
Views: 3519
Reputation: 1812
FCM clients require devices running Android 2.3 or higher that also have the Google Play Store app installed, or an emulator running Android 2.3 with Google APIs.
Upvotes: 1