简体   繁体   English

安装Facebook App后,Android Facebook登录API直接进入onCancel()

[英]Android Facebook Login API going directly to onCancel() when Facebook App is installed

So I've implemented Facebook Login in my Android app for a while now, and it's been working fine for months. 因此,我已经在Android应用程序中实现Facebook登录已有一段时间了,并且已经运行了好几个月。

The problems began when I updated the SDK version to one of the latest (4.22.0). 当我将SDK版本更新为最新版本(4.22.0)时,问题开始了。 After this point, clicking the Facebook Login button just causes a brief attempt at logging in and then nothing. 此后,单击“ Facebook登录”按钮只会导致短暂的登录尝试,然后什么也没有。 From the log I can see onCancel() in the FacebookCallback is being called but that's it. 从日志中,我可以看到正在调用FacebookCallback中的onCancel(),仅此而已。

Everything works fine when I uninstall the Facebook app. 当我卸载Facebook应用程序时,一切正常。 I go through the web view login and then I'm able to proceed (onSuccess() is called). 我通过Web视图登录,然后就可以继续(调用onSuccess()了)。

I've tried reverting back to the SDK version I was using earlier, but no luck. 我尝试过恢复到以前使用的SDK版本,但是没有运气。 I've checked that my KeyHashes match (both debug and release) what's on the Facebook Developer Dashboard, and it does. 我检查了我的KeyHashes是否匹配(调试和发布)以及Facebook Developer Dashboard上的匹配,并且匹配。 My App ID matches too.' 我的应用程序ID也匹配。”

I know that I'm logged out prior to attempting a login since I'm forcing a logout with LoginManager. 我知道在尝试登录之前我已经注销,因为我要使用LoginManager强制注销。

It's very odd. 这很奇怪。 I used the following code to generate my KeyHash: 我使用以下代码生成我的KeyHash:

try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    "***.*****.************",
                    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 (PackageManager.NameNotFoundException e) {

        } catch (NoSuchAlgorithmException e) {

        }

您需要具有签名的aPK KeyHash,因此,请在设备中运行已签名的APk和已签名的APK,并从调试日志中获取已签名的keyHash。该密钥哈希将更新到您的Facebook开发者控制台中。

Try to using that code for fackbook hash key generation. 尝试使用该代码来生成Fackbook哈希密钥。

 try {
            PackageInfo info = getPackageManager().getPackageInfo("enter your package", 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 (PackageManager.NameNotFoundException e) {

        } catch (NoSuchAlgorithmException e) {

        }

I used following steps to generate a Key Hash for my app in facebook: 我使用以下步骤在Facebook中为我的应用程序生成了密钥哈希:

  1. First open a terminal in mac (open a command prompt in windows). 首先在Mac中打开一个终端(在Windows中打开命令提示符)。
  2. Navigate in the terminal to the directory where your Android debug.keystore is stored. 在终端中导航到存储Android debug.keystore的目录。 Mostly in Windows it will located under “/Users/user_name/.android/” and in Windows will be C:\\Documents and Settings.android). 通常在Windows中,它将位于“ /Users/user_name/.android/”下,在Windows中将为C:\\ Documents and Settings.android)。

  3. In mac - Type cd ~/.android and hit enter to go to .android directory 在Mac中-输入cd〜/ .android,然后按Enter键进入.android目录

  4. Once you are in the “.android” directory, run the following command to get a debug key.. keytool -exportcert -alias androiddebugkey -keystore debug.keystore | 进入“ .android”目录后,运行以下命令以获取调试密钥。keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl sha1 -binary | openssl base64 openssl base64

  5. Use the same procedure to get the Release key. 使用相同的过程来获取Release键。 Just replace the command with the following and use your release key alias. 只需将命令替换为以下命令,然后使用释放密钥别名即可。 keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | keytool -exportcert-别名YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | "PATH FOR openssl.exe" sha1 -binary | sha1 -binary |“ openssl.exe的路径” | openssl base64 openssl base64

  6. When it prompts you for a password, type android and hit Enter 当提示您输入密码时,键入android并按Enter

  7. Copy the value printed in the terminal that ends with an “=” and paste it in the Key Hash field in Facebook. 复制在终端中以“ =”结尾的值,然后将其粘贴到Facebook的“密钥哈希”字段中。 Then click the Save Changes button. 然后单击“保存更改”按钮。

暂无
暂无

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

相关问题 Ionic 4:安装本机 facebook 应用程序时,使用 android 登录 facebook 失败 - Ionic 4: failed facebook login with android when the native facebook app is installed Facebook应用程序安装在android中的Facebook登录问题 - Facebook Login issue when facebook app is installed in android Android facebook 登录不适用于已安装的 Facebook 应用程序 - Android facebook login not working with installed Facebook app 安装Facebook App时,Android Facebook API错误与SSO - Android Facebook API errors with SSO when Facebook App installed 安装Facebook应用后,Facebook登录中断 - Facebook login breaks when Facebook app is installed android:使用facebook sdk 3登录facebook,未安装facebook应用 - android : facebook login using facebook sdk 3 with no facebook app installed Android上的Facebook Unity SDK - 安装FB App时登录失败 - Facebook Unity SDK on Android - Login fails when FB App installed 使用sdk 4.0的Android facebook登录首次返回onCancel() - Android facebook login with sdk 4.0 returns to onCancel() the first time 安装了Facebook本机应用程序后,服务器端Facebook登录是否无法在“ cordova android应用程序”上运行? - Server-side Facebook login stops working on a “cordova android app” when facebook native app is installed? 如果在模拟器上安装了Facebook应用,则无法登录到Facebook-Android 4.3 - Login to facebook does not work if facebook app is installed on emulator - Android 4.3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM