I ran into a problem while adding Firebase services into my app using android studio
here is the logcat:
2021-08-09 12:17:24.764 6480-6480/com.nanosoft.fawwalet
D/ActivityThread: ActivityThread::handleMakeApplication()
data=AppBindData{appInfo=ApplicationInfo{13e94c8
com.nanosoft.fawwalet}} appContext=android.app.ContextImpl@3aa7961
appContext.mOpPackageName=com.nanosoft.fawwalet
appContext.mBasePackageName=com.nanosoft.fawwalet
appContext.mPackageInfo=android.app.LoadedApk@2976c86
data.restrictedBackupMode= false data.providers=
[ContentProviderInfo{name=com.nanosoft.fawwalet.mobileadsinitprovider
className=com.google.android.gms.ads.MobileAdsInitProvider},
ContentProviderInfo{name=com.nanosoft.fawwalet.firebaseinitprovider
className=com.google.firebase.provider.FirebaseInitProvider},
ContentProviderInfo{name=com.nanosoft.fawwalet.workmanager-init
className=androidx.work.impl.WorkManagerInitializer},
ContentProviderInfo{name=com.nanosoft.fawwalet.lifecycle-process
className=androidx.lifecycle.ProcessLifecycleOwnerInitializer},
ContentProviderInfo{name=com.nanosoft.fawwalet
className=com.nanosoft.fawwalet.data.PlaceDetailProvider}] Caller=android.app.ActivityThread.handleBindApplication:7446
android.app.ActivityThread.access$1500:301
android.app.ActivityThread$H.handleMessage:2148
android.os.Handler.dispatchMessage:106 android.os.Looper.loop:246
2021-08-09 12:17:24.946 6480-6480/com.nanosoft.fawwalet I/FirebaseApp:
Device unlocked: initializing all Firebase APIs for app [DEFAULT] 2021-08-09 12:17:25.161 6480-6480/com.nanosoft.fawwalet
I/FirebaseInitProvider: FirebaseApp initialization successful
2021-08-09 12:17:25.583 6480-10717/com.nanosoft.fawwalet W/FA: Failed to retrieve Firebase Instance Id
Any help will be appreciated
here is my manifiest file
<service android:name=".utils.PushNotificationService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
I followed Firebase tutorials to establish my FCM but still no luck
heres the java class
public class PushNotificationService extends FirebaseMessagingService {
private static final String TAG = "PushNotification";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// ...
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
if (/* Check if data needs to be processed by long running job */ true) {
// For long-running tasks (10 seconds or more) use Firebase Job Dispatcher.
} else {
// Handle message within 10 seconds
}
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
}
@Override
public void onNewToken(@NonNull String s) {
super.onNewToken(s);
}
}
2
Answers
Solved by doing the following:
2.using mavenCentral()
I figured that myself while trying to reproduce the problem so it has nothing to do with Fire Base instance Id since I did not call it. Firebase services are up and running
In the PushNotificationService you need to override the method
onNewToken
this will give you the new token whenever the token is updated.