覆盖 firebase 应用程序的 DefaultInstance。重新初始化:java.lang.IllegalStateException:FirebaseApp 已删除

Overwrite DefaultInstance of the firebase app. Re-initialize: java.lang.IllegalStateException: FirebaseApp was deleted

我想在初始化后更改 FirebaseApp 配置,但出现错误 - “java.lang.IllegalStateException:FirebaseApp 已删除”

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

如何修复?

修复 - 已删除令牌,我们 Xamarin.Firebase.Messaging 而不是 PluginFirebasePushNotifications

 public async Task<bool> TryDeleteFirebaseAppAsync(string name)
    {
        var apps = FirebaseApp.GetApps(this);
        if (apps.Count != 0)
        {
            var app = apps.Where((i) => i.Name == name).FirstOrDefault();
            await FirebaseMessaging.Instance.DeleteToken();
            app.Delete();
            return true;
        }
        else
            return false;

    }

我的样本:FirebaseTestNotification