FirebaseInstanceIdService was deprecated .!
just override onNewToken()
in FirebaseMessagingService
public class LatestFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onNewToken(String mToken) {
super.onNewToken(mToken);
Log.e("TOKEN",mToken);
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
}}
InAndroidManifest.xml
<service
android:name=".LatestFirebaseMessagingService"
android:stopWithTask="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
getToken()
This is also deprecated.!
if you need to get token in your activity use the below code.
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener( MyActivity.this, new OnSuccessListener<InstanceIdResult>() {
@Override
public void onSuccess(InstanceIdResult instanceIdResult) {
String mToken = instanceIdResult.getToken();
Log.e("Token",mToken);
}
});