Android 上的 Facebook Unity SDK - 安装 FB 应用程序时登录失败 [英] Facebook Unity SDK on Android - Login fails when FB App installed

查看:43
本文介绍了Android 上的 Facebook Unity SDK - 安装 FB 应用程序时登录失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎遇到了与此问题中讨论的相同的问题:Android 版 Unity 的 Facebook SDK - 麻烦关于 FB.Login 的回调

I appear to be having the same issue as discussed in this question: Facebook SDK for Unity on Android - Trouble about callback from FB.Login

在 Android 上,当安装了常规 Facebook 应用程序时,使用 Unity SDK 调用 FB.Login() 会提示用户接受应用程序的权限,当应用程序获得批准时,回调将被触发:FBResult.Text

On Android when the regular Facebook app is installed, calls to FB.Login() using the Unity SDK prompt the user to accept permissions for the app and when the app is approved the callback is fired with: FBResult.Text

{"is_logged_in":false,"user_id":"","access_token":""}

FBResult.Error

FBResult.Error

null

安装 Facebook 应用后,使用网络流并且工作正常,但是我已经尝试使用 Unity SDK 的 v4.2.4 和 v4.2.2.

When the Facebook app is installed the web flow is used and works fine, I have however tried this with v4.2.4 and v4.2.2 of the Unity SDK.

关于解决这个问题还有其他建议吗?

Any other advice on getting this resolved?

还应该注意,我已经在 2 个不同的设备(Galaxy Note 10.1 和 Nexus 7)上尝试了这个

Should also note, I've tried this on 2 different devices (Galaxy Note 10.1 and Nexus 7)

提前致谢!

2014 年的说明.在某些情况下,问题很简单,因为您忘记了 developer.facebook 上的设置.布赖恩在这里用图片解释:http://answers.unity3d.com/questions/543540/facebook-sdk-v424-android-login-not-working.html 令人困惑的是它会在没有 fb 应用程序的设备上工作(!),如果你有完全忘记设置了.至于实际问题,幸运的是有解决方案,即使您在 Mac 上使用 Unity 也很简单:http://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html

A note for 2014. In some cases the problem is very simply that you've forgotten the settings on developers.facebook. Brian explains it here with images: http://answers.unity3d.com/questions/543540/facebook-sdk-v424-android-login-not-working.html Confusingly it WILL WORK (!) on devices WITHOUT the fb app, if you have completely forgotten the settings. As to the actual problem, fortunately there is a solution even if you are using Unity on Mac and it is simple: http://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html

推荐答案

感觉好傻,最终自己解决了,通过部署到一个中间的谷歌安卓项目,我能够使用logcat获得一个更有用的错误留言:

Ach feel so silly, eventually managed to solve it myself, by deploying to an intermediary Google Android Project, I was able to use logcat to obtain a more useful error messsage:

remote_app_id 与存储的 id 不匹配

remote_app_id does not match stored id

从那里我找到了与标准 Android SDK 相关的主题:Android Facebook SDK 3.0 给出remote_app_id 与存储的 id 不匹配"登录时

From there I found this topic relating to the standard Android SDK: Android Facebook SDK 3.0 gives "remote_app_id does not match stored id" while logging in

最后通过用这段代码片段获得的Key Hash替换Key Hash解决了问题

And finally solved the problem by replacing the Key Hash with the one obtained by this code snippet

try {
PackageInfo info = getPackageManager().getPackageInfo(
      "com.facebook.samples.loginhowto", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures){
       MessageDigest md = MessageDigest.getInstance("SHA");
       md.update(signature.toByteArray());
       Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

当然用你自己的包名替换 com.facebook.samples.loginhowto

来源:https://stackoverflow.com/a/14421260/2823496

通过命令行或 Unity 获得正确的密钥哈希似乎取决于安装了正确版本的 openssl(并存储在 PATH 中),但不知道那是什么版本.(尝试了链接答案中的那个)所以请注意其他为此而苦苦挣扎的人.

It seems getting the correct keyhash, via command line or through Unity depends on having the right version of openssl installed (and stored in PATH) but no idea what version that is. (tried the one in linked answer) So heads up to anyone else struggling with this.

注意 - 如果您使用 Mac 进行 Unity 开发,几乎不可能做到这一点.在这种情况下,这是幸运的简单解决方案 http://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html

Note - it's almost impossible to do this if you're using Mac for Unity development. Here's the fortunately simple solution in that case http://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html

这篇关于Android 上的 Facebook Unity SDK - 安装 FB 应用程序时登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆