'Overwrite DefaultInstance of the firebase app. Re-initialize: java.lang.IllegalStateException: FirebaseApp was deleted
I want to change the FirebaseApp configuration after initialization, but get an error - "java.lang.IllegalStateException: FirebaseApp was deleted"
var apps = FirebaseApp.GetApps(Context);
if (apps.Count != 0 )
{
apps.Where((i) => i.Name == FirebaseApp.DefaultAppName).FirstOrDefault().Delete();
}
var options = new FirebaseOptions.Builder()
.SetApiKey(config["API_KEY"])
.SetApplicationId(config["GOOGLE_APP_ID"])
.SetGcmSenderId(config["GCM_SENDER_ID"])
.SetProjectId(config["PROJECT_ID"])
.SetStorageBucket(config["STORAGE_BUCKET"])
.Build();
FirebaseApp.InitializeApp(Context, options);
if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
{
//Change for your default notification channel id here
FirebasePushNotificationManager.DefaultNotificationChannelId = "FirebasePushNotificationChannel";
//Change for your default notification channel name here
FirebasePushNotificationManager.DefaultNotificationChannelName = "General";
FirebasePushNotificationManager.DefaultNotificationChannelImportance = NotificationImportance.Max;
}
FirebasePushNotificationManager.Initialize(Context, false);
How to fix?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
