简体   繁体   中英

Unable to login / Facebook Unity SDK & Android

Facebook Unity SDK: 5.0.3 beta

When I try to login having installed Facebook app it asks me if I'll allow this app to access my profile (then I can see on facebook in my profile applications page that access is given indeed), but nothing happens after this. Interactive console (example which comes with Unity SDK) still shows no signs that I've been logged.

Here is what happens in logcat when I press login button:

D/FBUnitySDK(21729): KeyHash: BR6n1yxjFrxzrkkeDey3fzy7Mb0=
V/FBUnitySDK(21729): sending to Unity OnLoginComplete({"cancelled":true,"key_hash":"BR6n1yxjFrxzrkkeDey3fzy7Mb0=\n"})

If I'll remove facebook app then it'll show me small webview, where I should enter my credentials. After entering it it'll simply reappering again with both input fields empty and there is no end to this reappearing (unless I give up and press Cancel/X).

Here is what happens in logcat when I trying to login in webview:

D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/dialog/oauth?display=touch&e2e=%7B%22init%22%3A1391609676100%7D&client_id=620142358054713&scope=email&type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/dialog/oauth?display=touch&e2e=%7B%22init%22%3A1391609676538%7D&client_id=620142358054713&scope=email&type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess
D/FacebookSDK.WebDialog(21729): Redirect URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=620142358054713&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Demail%26type%3Duser_agent%26client_id%3D620142358054713%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26e2e%3D%257B%2522init%2522%253A1391609676538%257D&display=touch&_rdr
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=620142358054713&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Demail%26type%3Duser_agent%26client_id%3D620142358054713%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26e2e%3D%257B%2522init%2522%253A1391609676538%257D&display=touch&_rdr
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=620142358054713&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Demail%26type%3Duser_agent%26client_id%3D620142358054713%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26e2e%3D%257B%2522init%2522%253A1391609676538%257D&display=touch&_rdr
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/login.php?skip_api_login=1&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Demail%26type%3Duser_agent%26client_id%3D620142358054713%26ret%3Dlogin&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&refid=9
D/FacebookSDK.WebDialog(21729): Redirect URL: https://m.facebook.com/dialog/oauth?redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&scope=email&type=user_agent&client_id=620142358054713&ret=login&ext=1391613294&hash=Aea6t5pfgOeXQyOH&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&refid=9&m_sess=c2VzczoxMDAwMDU2MzQ0ODY4ODI6Mjk6Uk5FLWFfTXV5RE9ZeHc6MjoxMzkxNjA5Njk0OjE0MDMx&_rdr#_=_
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/dialog/oauth?redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&scope=email&type=user_agent&client_id=620142358054713&ret=login&ext=1391613294&hash=Aea6t5pfgOeXQyOH&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&refid=9&m_sess=c2VzczoxMDAwMDU2MzQ0ODY4ODI6Mjk6Uk5FLWFfTXV5RE9ZeHc6MjoxMzkxNjA5Njk0OjE0MDMx&_rdr#_=_
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/dialog/oauth/confirm
D/FacebookSDK.WebDialog(21729): Redirect URL: fbconnect://success#access_token=xxx&expires_in=5179467
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/dialog/oauth?display=touch&e2e=%7B%22init%22%3A1391609698785%7D&client_id=620142358054713&scope=email&type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess
D/FacebookSDK.WebDialog(21729): Redirect URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=620142358054713&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Demail%26type%3Duser_agent%26client_id%3D620142358054713%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26e2e%3D%257B%2522init%2522%253A1391609698785%257D&display=touch&_rdr
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=620142358054713&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Demail%26type%3Duser_agent%26client_id%3D620142358054713%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26e2e%3D%257B%2522init%2522%253A1391609698785%257D&display=touch&_rdr
D/FacebookSDK.WebDialog(21729): Webview loading URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=620142358054713&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Demail%26type%3Duser_agent%26client_id%3D620142358054713%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26e2e%3D%257B%2522init%2522%253A1391609698785%257D&display=touch&_rdr

Login on IOS works just fine, but what's wrong I could be doing with android?

UPDATE: Everything works as should on 4.3.6 SDK version

Are you logging in without any permissions? There's a known bug where FB.Login() doesn't work if no permissions is specified. Try FB.Login("basic_info", <your_callback>)

see: Unity Beta SDK 5.0.3 - Problems logging in on Android device

Login works only when I start logging in in portrait screen mode. If I start it in landscape - it forcefully changes to portrait and back but nothing happens aside from that. Tested a few times without rebuilding - confirmed. I believe this to be a bug.

There is a serious issue in the SDK.

The SDK uses phantom activity FBUnityLoginActivity , which calls FB.LoginUsingActivity() from onCreate() But the activity has no android:configChanges attribute, and it gets restarted by Android, because it switches from lansdcape to portrait. It results in a second call to FB.LoginUsingActivity() , which cancels previous asynchronous login.

The solution is to specify correct android:configChanges and android:screenOrientation on all activities.

I think Facebook team should use runOnUiThread() instead of phantom activity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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