检索Firebase实例Id失败(没有Firebase服务正在工作)



我在使用android studio将Firebase服务添加到我的应用程序时遇到了一个问题下面是日志目录:

2021-08-09 12:17:24.764 6480-6480/com.nanosoft.fawwaletD/ActivityThread: ActivityThread:: handleMakeApplication ()data = AppBindData {appInfo = ApplicationInfo {13 e94c8com.nanosoft。fawwalet}} appContext = android.app.ContextImpl@3aa7961appContext.mOpPackageName = com.nanosoft.fawwaletappContext.mBasePackageName = com.nanosoft.fawwaletappContext.mPackageInfo = android.app.LoadedApk@2976c86数据。restrictedBackupMode= false[ContentProviderInfo {name = com.nanosoft.fawwalet.mobileadsinitproviderclassName = com.google.android.gms.ads.MobileAdsInitProvider},ContentProviderInfo {name = com.nanosoft.fawwalet.firebaseinitproviderclassName = com.google.firebase.provider.FirebaseInitProvider},ContentProviderInfo {name = com.nanosoft.fawwalet.workmanager-initclassName = androidx.work.impl.WorkManagerInitializer},ContentProviderInfo {name = com.nanosoft.fawwalet.lifecycle-processclassName = androidx.lifecycle.ProcessLifecycleOwnerInitializer},ContentProviderInfo {name = com.nanosoft.fawwaletclassName = com.nanosoft.fawwalet.data.PlaceDetailProvider}]调用者= android.app.ActivityThread.handleBindApplication: 7446android.app.ActivityThread.access 1500:301美元android.app.ActivityThread H.handleMessage: 2148美元handler。dispatchMessage: 106 android.os.Looper.loop: 2462012-08-09 12:17:24.946 6480-6480/com.nanosoft。fawwalet I/FirebaseApp:设备解锁:为应用程序初始化所有Firebase api [DEFAULT]20121-08-09 12:17:25.161 6480-6480/com.nanosoft.fawwaletI/FirebaseInitProvider: FirebaseApp initialization successful2013-08-09 12:17:25.583 6480-10717/com.nanosoft。fawwalet W/FA: Failed to retrieve Firebase Instance Id

任何帮助都将不胜感激

这是我的manifest文件

<service android:name=".utils.PushNotificationService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

我遵循Firebase教程建立我的FCM,但仍然没有运气

这里是Java类

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);
}
}

在PushNotificationService中,你需要重写方法onNewToken,这将在令牌更新时给你新的令牌。

解决方法如下:

  1. 将google play服务降级为'com.google.gms:google-services:4.3.8' = 4.3.9

2。使用mavenCentral ()

  1. raise minSdkVersion 18 was 16

我认为我自己,而试图重现的问题,所以它与Fire基地实例Id无关,因为我没有调用它。Firebase服务启动并运行

最新更新