简体   繁体   English

安装FB应用程序后Facebook登录失败

[英]Facebook login fails with FB app installed

Using Unity 4.3 and Facebook SDK 5.0.3 / 5.0.4 beta I seem to be unable to log in to Facebook on Android using FB.Login("publish_actions", LoginCallback). 使用Unity 4.3和Facebook SDK 5.0.3 / 5.0.4 beta,我似乎无法使用FB.Login(“ publish_actions”,LoginCallback)在Android上登录Facebook。 My game shows the "Game would like to post to your friends on your behalf"-message. 我的游戏显示“游戏想代表您发布给朋友”的消息。 After tapping OK, I get an ajax-spinner for about 2-3 seconds after which I'm brought back to my game without being able to post a FB.Feed. 点击“确定”后,我得到了一个ajax旋转程序约2-3秒,此后,我又无法发布FB.Feed而回到我的游戏中。

The message I'm getting is: 我收到的消息是:

V/FBUnitySDK( 8892): sending to Unity OnLoginComplete({"cancelled":true,"key_hash":"XXXXXXXXXXXXXXXXXXX"})

As soon as I remove the Facebook app, everything seems to work fine and I'm getting a popup that asks for my publish_actions permissions. 删除Facebook应用程序后,一切似乎都可以正常运行,并且出现一个弹出窗口,要求我的publish_actions权限。

I also looked into the key hash problem and was able to find the correct key_hash by getting FB.Android.KeyHash. 我还研究了密钥哈希问题,并通过获取FB.Android.KeyHash能够找到正确的key_hash。

Is there a way around this? 有没有解决的办法?

if there is the default Facebook App is installed in your phone or if you are trying to upload your app on Google Play, then you need a different KeyHash. 如果您的手机中安装了默认的Facebook App,或者您尝试在Google Play上上传您的应用,则需要其他KeyHash。 because, when u developed your FB app you have registered your FB app with a key hash which is created by using the default debug.keystore. 因为,当您开发FB应用程序时,您已使用默认的debug.keystore创建的密钥哈希注册了FB应用程序。

so, now u need a different KeyStore to generate the different KeyHash. 因此,现在您需要一个不同的KeyStore来生成不同的KeyHash。 u need a signed KeyStore, which u can get by the help of this tutorial , after generating new keystore, generate a key hash and register your FB App with this new key hash. 您需要一个签名的KeyStore,您可以在本教程的帮助下获得该密钥,在生成新的密钥库之后,生成一个密钥哈希并使用此新的密钥哈希注册FB应用。 this should work. 这应该工作。 for generating new KeyHash u can follow this link . 要生成新的KeyHash,您可以点击此链接

Okay, I finally figured it out. 好吧,我终于明白了。

On Mac, in Terminal, enter the following: 在Mac上的“终端”中,输入以下内容:

keytool -list -keystore pathtokeystorefile.keystore | openssl sha1 -binary | openssl base64

You'll be prompted to enter the password. 系统将提示您输入密码。 Do so and you will get your valid KeyHash. 这样做,您将获得有效的KeyHash。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM