I was trying to get the FCM working in my app in the past few days, and I saw that the onTokenRefreshed() function and FirebaseInstanceIdService in general, is deprecated. So I followed some firebase documentations and tutorials online, but none of them seemed to be working for me. My MyFirebaseMessagingService class is:
package com.example.android.aln4.Classes;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMessaging";
@Override
public void onNewToken(String token) {
super.onNewToken(token);
Log.d(TAG,"Refreshed token: "+token);
}
}
and my manifest contains this following code:
<service android:name=".Classes.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Plus, all of my firebae-related implemetations are up-to-date, as the following:
//Firebase
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:2.1.1'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-firestore:18.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
My problem in general, is that whenever I run the app, doesn't matter if it's after uninstalling and installing or on a regular run, the onNewToken() function is not called, or at least I don't see it in the Logcat. Any sort of help would be appriciated :)