Facebook SDK 3.1.2 for Unity - Trouble logging in on Android Devices

白昼怎懂夜的黑 提交于 2020-01-04 01:52:12

问题


I'm using the latest version of the Facebook SDK, version 3.1.2, for Unity. My problem is somewhat similar to this question. The differences being that my iOS builds work just fine. And my Android builds aren't getting null references. Instead, My android build will just not log in.

When I click my login button, it'll bring up the dialogue screen to give the app permission to access the basic stuff, public profile and friend list. Upon hitting the ok button, it'll return me to my app but fail the login. I found the AndroidFacebook class and noticed that OnLoginComplete function has a string message param where it should grab the user's id and access token from. So I put a debug message in there to see what was being returned. It turns out that although I press ok to give the app access to facebook, it's saying that the process was cancelled. {"cancelled":true} is the Json string being returned. I've doubled check my app settings in the facebook developer page and the Package name, class name and debug hash key all match what I have in the Unity Facebook settings. I've even tried with the Sandbox mode on and off.


回答1:


It sounds like you don't have the android key hash set up correctly. In the Unity Editor, click the Facebook entry on the main menu bar, then click "Edit Settings". Find the item marked "Debug Android Key Hash" and copy the value to your clipboard.

Navigate to http://apps.facebook.com and find you app. Paste the key hash you took from the editor into the "Key Hashes" section of your apps native android setup. This page has a picture of how your setup should end up looking.




回答2:


Does your main activity extend the FBUnityPlayerActivity class?

We're running into the same problem, and tried the same fixes - just now noticing this as a warning in the editor logs.



来源:https://stackoverflow.com/questions/18875262/facebook-sdk-3-1-2-for-unity-trouble-logging-in-on-android-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!