Firebase Unity Facebook登录不返回/保存电子邮件

问题描述 投票:0回答:1

我正在使用Firebase允许用户通过Facebook登录到Unity游戏。它工作正常,但是使用此参数auth.CurrentUser.Email无法访问用户的电子邮件。此外,电子邮件也不存储在Firebase身份验证控制台中。当我使用其他登录方法(例如电子邮件和Google)时,可以成功存储/访问电子邮件。

这是我的代码:

    public void SignInFacebook()
    {
        var perms = new List<string>() { "public_profile", "email", "user_friends" };
        FB.LogInWithReadPermissions(perms, AuthCallback);
    }

    private void AuthCallback(ILoginResult result)
    {
        if (FB.IsLoggedIn)
        {
            // AccessToken class will have session details
            var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
            // Print current access token's User ID
            Debug.Log(aToken.UserId);
            // Print current access token's granted permissions
            foreach (string perm in aToken.Permissions)
            {
                Debug.Log(perm);
            }

            Credential credential = FacebookAuthProvider.GetCredential(aToken.TokenString);
                auth.SignInWithCredentialAsync(credential).ContinueWithOnMainThread(task => {
                    if (task.IsCanceled)
                    {
                        Debug.LogError("SignInWithCredentialAsync was canceled.");
                        return;
                    }
                    if (task.IsFaulted)
                    {
                        Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                        return;
                    }

                    Firebase.Auth.FirebaseUser newUser = task.Result;
                    Debug.LogFormat("User signed in successfully: {0} - {2} - ({1})",
                        newUser.DisplayName, newUser.UserId, newUser.Email);
                });
        }
        else
        {
            Debug.Log("User cancelled login");
        }
    }

这就是控制台中的外观(“-”是应该存储电子邮件的位置。如果我使用其他登录方法,例如email或google,则电子邮件将没有任何问题地存储)] >

enter image description here

关于此问题的类似问题,有人建议我将Firebase中的帐户电子邮件地址设置

更改为防止创建具有相同电子邮件地址的多个帐户,但这并不能解决问题。

谢谢!

我正在使用Firebase允许用户通过Facebook登录到Unity游戏。它工作正常,但使用此参数auth.CurrentUser.Email无法访问用户的电子邮件。此外,...

c# firebase facebook unity3d facebook-sdk-4.0
1个回答
0
投票

您可以尝试这个

© www.soinside.com 2019 - 2024. All rights reserved.