Plugin.FirebaseAuth.FirebaseAuthException:访问钥匙串 Xamarin.forms 应用程序时出错

问题描述

我使用的是 Plugin.FirebaseAuth (4.1.0) 的最新稳定包。但是当我尝试在使用 iOS 模拟器时调用 SignInWithEmailAndPasswordAsync(email,password) 时。我得到了一个例外?

方法

public async Task<bool> SignIn(string email,string password)
{
    try
    {

        var result = await CrossFirebaseAuth.Current.Instance.SignInWithEmailAndPasswordAsync(email,password);
        var token = await result.User.GetIdTokenAsync(true);
        Preferences.Set("MyFirebaseRefreshToken",token);
        AccountManager.CurrentUserId = result.User.Uid;
        return true;
    }
    catch (FirebaseAuthException ex)
    {
        Console.WriteLine(ex.Reason);
        await App.Current.MainPage.displayAlert($"Alert",(ex.Reason.ToString()),"OK");
        return false;
    }
}`

错误

enter image description here

解决方法

如果只发生在 ios 上,那可能是因为您没有在 App ID 前添加 Team ID 前缀。像这样:

Auth.auth().useUserAccessGroup("XK********.com.matkonit.SharedItems")

您可以参考this page

,

好的 所以问题出在 iOS 模拟器上。

修复: 您需要一个苹果开发者帐户和一个配置文件。你还需要一个自定义的 entitlements.plist