9
votes

I appear to be having the same issue as discussed in this question: Facebook SDK for Unity on Android - Trouble about callback from FB.Login

On Android when the regular Facebook app is installed, calls to FB.Login() using the Unity SDK prompt the user to accept permissions for the app and when the app is approved the callback is fired with: FBResult.Text

{"is_logged_in":false,"user_id":"","access_token":""}

FBResult.Error

null

When the Facebook app is installed the web flow is used and works fine, I have however tried this with v4.2.4 and v4.2.2 of the Unity SDK.

Any other advice on getting this resolved?

EDIT: Should also note, I've tried this on 2 different devices (Galaxy Note 10.1 and Nexus 7)

Thanks in advance!


A note for 2014. In some cases the problem is very simply that you've forgotten the settings on developers.facebook. Brian explains it here with images: http://answers.unity3d.com/questions/543540/facebook-sdk-v424-android-login-not-working.html Confusingly it WILL WORK (!) on devices WITHOUT the fb app, if you have completely forgotten the settings. As to the actual problem, fortunately there is a solution even if you are using Unity on Mac and it is simple: http://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html

2
Would it be possible for you to send us your project so we can try to debug it? Use [email protected] if you want to send us a link for download (or just attach it). Thanks for the detailed report!aaron
Sorry had it fixed already but stackoverflow didn't want me answering my own question quite yet. Perhaps there would be a more intuitive way to return that error to Unity SDK though? :)Brizee
@BrianBeacom Hi I am facing the same issue with the plugin. Even entered the hashkey that comes in the log into the developer console. BUT I am very much unsure on how to do this. Some topics suggested--- --> The FB app should be updated to the latest one. --> The hashkey generated in the logcat should be entered into the dev console. --> We have to create a keystore(our own) and put the generated hashkey into the dashboard. I did all the steps and still I'm stuck into the same problem. Perhaps you can guide me into it.Siddharth-Verma
@user1683989 Hey so you'll wanna put the hashkey generated in logcat into your Facebook Dev Dash, go here pick your app then either Settings or Edit depending on which version of FB you get, from there you need to find the list of platforms and if it's not there Add Android and pop your hashkey in the Key Hashes section under it.Brizee
@user1683989 The version of Facebook installed (or if it's installed at all) shouldn't matter as the keyhash is generated by Android not Facebook, Facebook just uses it for authenticity. Keystores and such don't matter and you won't need to put it anywhere in Unity. As long as you don't change the bundle identifier you should be fine.Brizee

2 Answers

5
votes

Ach feel so silly, eventually managed to solve it myself, by deploying to an intermediary Google Android Project, I was able to use logcat to obtain a more useful error messsage:

remote_app_id does not match stored id

From there I found this topic relating to the standard Android SDK: Android Facebook SDK 3.0 gives "remote_app_id does not match stored id" while logging in

And finally solved the problem by replacing the Key Hash with the one obtained by this code snippet

try {
PackageInfo info = getPackageManager().getPackageInfo(
      "com.facebook.samples.loginhowto", 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 (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

Replacing com.facebook.samples.loginhowto with your own package name of course

Source: https://stackoverflow.com/a/14421260/2823496

It seems getting the correct keyhash, via command line or through Unity depends on having the right version of openssl installed (and stored in PATH) but no idea what version that is. (tried the one in linked answer) So heads up to anyone else struggling with this.


Note - it's almost impossible to do this if you're using Mac for Unity development. Here's the fortunately simple solution in that case http://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html

0
votes

I had a same error. And i have remove facebook app. My app is working fine


MORE ON THAT: https://stackoverflow.com/a/23446140/294884