[英]Login with Facebook latest sdk if native app install then dialog not open in android
I am using latest Facebook-sdk for Login with Facebook我正在使用最新的 Facebook-sdk登录 Facebook
implementation 'com.facebook.android:facebook-login:[5,6)'
Try to login with facebook using custom button
I am also getting this error in Facebook-android-sdk
github issue https://github.com/facebook/facebook-android-sdk/issues/580 this issue resolved or not.尝试使用
custom button
登录 facebook 我也在Facebook-android-sdk
github 问题https/github-issue.com/ facebook/facebook/facebook-android-sdk 中收到此错误
I want to open dialog if Facebook native app install, for that first I logout
using LoginManager.getInstance().logOut()
如果安装了 Facebook 本机应用程序,我想打开对话框,首先我使用
LoginManager.getInstance().logOut()
logout
I use default login manager like LoginManager.getInstance()
, then login and logout, but when i check token after logout like this AccessToken.getCurrentAccessToken()
it still exists我使用像
LoginManager.getInstance()
这样的默认登录管理器,然后登录和注销,但是当我像这样AccessToken.getCurrentAccessToken()
注销后检查令牌时它仍然存在
Below are my code:以下是我的代码:
callbackManager =
CallbackManager.Factory.create()
LoginManager.getInstance().logOut()
loginManager = LoginManager.getInstance()
LoginManager.getInstance()
.registerCallback(callbackManager, object : FacebookCallback<LoginResult> {
override fun onSuccess(loginResult: LoginResult) {
val graphRequest = GraphRequest.newMeRequest(loginResult.accessToken)
{ jsonObj, _ ->
}
val parameters = Bundle()
parameters.putString("fields", "id,name,email")
graphRequest.parameters = parameters
graphRequest.executeAsync()
}
override fun onCancel() {
}
override fun onError(error: FacebookException) {
var msg = ""
}
})
loginManager.logInWithReadPermissions(
this@SignUpActivity,
listOf("email", "public_profile")
)
Manifest
file Manifest
文件
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
Finally, I found solution after lots of research and read many answers.最后,经过大量研究并阅读了许多答案,我找到了解决方案。
If your app in development mode then generate Development Key Hash如果您的应用程序处于开发模式,则生成开发密钥 Hash
For Windows use following command:对于 Windows使用以下命令:
keytool -exportcert -alias androiddebugkey -keystore "C:\Users\USERNAME\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64
If your app in Release mode then Generate a Release Key Hash如果您的应用程序处于发布模式,则生成发布密钥 Hash
keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64
Hope this save your time...希望这可以节省您的时间...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.