简体   繁体   English

Firebase 手机登录失败

[英]Firebase login failed on mobile

I have a application in unity.我有一个统一的应用程序。 I can login to firebase in my pc and when I create an.exe but when I generate an apk the login failed.我可以在我的电脑上登录 firebase,当我创建 an.exe 时,但是当我生成 apk 时,登录失败。 Should I configure anything else?我应该配置其他东西吗?

My script我的脚本

void Start()
{
    auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
}

public void Login()
{
    string email = inputFieldEmail.text;
    string password = inputFieldPassword.text;

    auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
        if (task.IsCanceled)
        {
            Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");
            return;
        }
        if (task.IsFaulted)
        {
            Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception);
            return;
        }

        Firebase.Auth.FirebaseUser newUser = task.Result;
        Debug.LogFormat("User signed in successfully: {0} ({1})",
            newUser.DisplayName, newUser.UserId);
        GameManager.instance.SetNombre(email.Split('@')[0]);
        signedIn = true;
    });
}

Yes, you should configure on your Firebase console your mobile device keys.是的,您应该在您的 Firebase 控制台上配置您的移动设备密钥。 Also remember that Firebase is currently working with API 16+.另请记住,Firebase 目前正在与 API 16+ 合作。

More information here: https://firebase.google.com/docs/unity/setup更多信息在这里: https://firebase.google.com/docs/unity/setup

Some brief advice on that code, try replacing ContinueWith with ContinueWithOnMainThread .关于该代码的一些简短建议,请尝试将ContinueWith替换为ContinueWithOnMainThread This will make it easier to debug your code, and avoid any thread-related issues in Unity (in particular, your GameManager.instance.SetNombre makes me nervous).这将使您更容易调试代码,并避免 Unity 中出现任何与线程相关的问题(尤其是您的GameManager.instance.SetNombre让我感到紧张)。 It's a drop in replacement.这是一个下降的替代品。

For authentication to work on Android, you need three things:要在 Android 上进行身份验证,您需要三样东西:

  1. a google-services.json file (there's a chance that you have a GoogleService-Info.plist if you registered an iOS app).一个 google-services.json 文件(如果您注册了一个 iOS 应用程序,您就有可能拥有一个 GoogleService-Info.plist)。 From the help site :帮助网站
  1. Get config file for your Android app Go to your the Project settings in the Firebase console.将 Android 应用程序 Go 的配置文件获取到 Firebase 控制台中的项目设置。
  2. In the Your apps card, select the package name of the app for which you need a config file.在您的应用卡中,select 您需要配置文件的应用的名称 package。
  3. Click google-services.json.单击 google-services.json。
  4. Move your config file into the module (app-level) directory of your app.将配置文件移动到应用程序的模块(应用程序级)目录中。 Make sure that you only have this most recent downloaded config file in your app.确保您的应用程序中只有这个最近下载的配置文件。

(note for step 4 in Unity - just put it somewhere in your Assets/ directory) (请注意 Unity 中的第 4 步 - 只需将其放在您的 Assets/ 目录中的某个位置)

  1. Make sure that you've enabled analytics in your Firebase console.确保您已在 Firebase 控制台中启用分析。 It sounds like you've done this already.听起来你已经这样做了。

  2. Add your SHA-1 to Firebase. This is based on signing key, so each developer may need to register their local development SHA-1, and you'll want to register your final signing key.将您的 SHA-1 添加到 Firebase。这是基于签名密钥的,因此每个开发人员可能需要注册他们的本地开发 SHA-1,并且您需要注册您的最终签名密钥。 From the help site :帮助网站

Follow these steps if you didn't initially provide a SHA certificate fingerprint for your Firebase Android app or if you need to add an additional one.如果您最初没有为您的 Firebase Android 应用程序提供 SHA 证书指纹,或者如果您需要添加一个额外的指纹,请按照这些步骤操作。

  1. Make sure that you have the SHA fingerprint of your signing certificate.确保您拥有签名证书的 SHA 指纹。
  2. In your Project settings, go to the Your apps card.在您的项目设置中,go 到您的应用卡片。
  3. Select the Firebase Android app to which you want to add a SHA fingerprint. Select Firebase Android 要添加 SHA 指纹的应用程序。
  4. Click Add fingerprint.单击添加指纹。
  5. Enter or paste the SHA fingerprint, then click Save.输入或粘贴 SHA 指纹,然后单击保存。

To get your development SHA-1 key , enter roughly this command:获取您的开发 SHA-1 密钥,大致输入以下命令:

keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

And if you can't run the keytool command, I wrote this brief explainer .如果您不能运行 keytool 命令,我写了这个简短的解释器。 You can find it in your JDK directory (you have a JDK somewhere if you're making Android builds).您可以在您的 JDK 目录中找到它(如果您正在构建 Android,则在某处有一个 JDK)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 登录失败 - Firebase login failed Firebase 登录时出现“Auth.network-request-failed”错误的项目结果 - Firebase Project Results in "Auth/network-request-failed" error on login Firebase Auth 登录尝试失败次数过多是否会受到惩罚? - Is there a penalty for too many failed Firebase Auth login attempts? Firebase 当我使用手机浏览器使用 Facebook 登录时出现身份验证问题 - Firebase Authentication problen when i use mobile browser to login using Facebook login Firebase 身份验证错误 17010(帐户访问因登录尝试失败次数过多而被禁用)未被强制执行? - Firebase Auth error 17010 (account access disabled from too many failed login attempts) not being enforced? React Native:尝试创建新用户时出现 firebase auth/network-request-failed 错误,但在登录时却没有? - React Native: firebase auth/network-request-failed error when trying to create a new user, but not on login? 登录 Firebase/Flutter - Login Firebase/Flutter Facebook 在 Expo 中登录 Firebase “URL 被阻止:此重定向失败,因为重定向 URI 未在应用程序的客户端 OAuth 设置中列入白名单。” - Facebook Login in Firebase in Expo "URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings." Firebase 函数部署失败 - Firebase functions failed to deploy 在 Firebase 上反应的登录页面 - Login Page With React On Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM