problems with Facebook App for Android

I’ve read other topics about problems with the Facebook App. People have reported that the facebook api (for example, the sample Facebook app included with Corona) will work fine when no Facebook App is installed, but then when the Facebook App is installed, if you try to login or post from Corona, it will cause the Facebook App to open for a few seconds and then return to the Corona app.

Well I thought I was having that problem. It turns out it’s a bit stranger. If I have no Facebook App, everything works fine. If I do have it, then the behaviour depends on whether or not I’m logged in through that app. If I’m not logged in, then when I try to login or post from Corona, the Facebook App will open and ask me to log in. After I log in, I can post from Corona, but Corona doesn’t seem to be receiving the OAuth Tokens. Furthermore, I logged into the Facebook app and then did a fresh install of the Corona sample Facebook app. Without submitting any login details after the Corona app installation, I was able to post messages from Corona. It seems that the Facebook app will accept post requests from any other app, regardless of whether or not that app has the OAuth Tokens.

I assume the above problem is with the Facebook App. It absolutely should not be allowing apps to post as a user without any permissions from the user. However, as a byproduct, I’m not able to tell if the user has successfully logged in or not from my Corona code. I’m just wondering why Corona is communicating to Facebook via the Facebook app. Is there any way Corona can handle Facebook consistently, independent of whether the Facebook app is installed? [import]uid: 103727 topic_id: 26868 reply_id: 326868[/import]

Hello, what version of Corona did you test this on? [import]uid: 84637 topic_id: 26868 reply_id: 109077[/import]

Hello. This was tested on 2012.799 [import]uid: 103727 topic_id: 26868 reply_id: 109153[/import]

The fixes for facebook issues were introduced in daily build 817.

Please try that build and report back :slight_smile: [import]uid: 84637 topic_id: 26868 reply_id: 109186[/import]

Ok I followed these exact steps:

  1. Build the Corona Facebook sample app with 2012.825

  2. Uninstall the Corona Facebook sample app previously built with 2012.799

  3. Check official Facebook App for Android to make sure I was logged in.

  4. Install the Corona Facebook sample app built with 2012.825

  5. Open the Corona Facebook sample app and press “Post Msg”

The Facebook App opened, showed a progress spinner, and then returned to the Corona sample app. I checked my facebook and the message was posted successfully from Corona without the Corona app providing any credentials. [import]uid: 103727 topic_id: 26868 reply_id: 109435[/import]

This is expected behavior. It’s the workflow defined by Facebook itself. Corona merely wraps up calls into the Facebook SDK.

What the Facebook SDK does is it looks for the Facebook app, and if installed, use the credentials stored in the Facebook app on the user’s behalf.

If the FB app is not present, it will fallback to the workflow you’ve observed.
[import]uid: 26 topic_id: 26868 reply_id: 109442[/import]

When the Facebook App is installed, does the Facebook SDK return any of the following information to Corona:

  1. Is the Facebook App installed?
  2. Is the user logged in through the Facebook App?
  3. Has the user granted permissions to allow Corona to post on their behalf?

Without 1 or 2, a Corona app has no way to know whether or not to display a “login/logout” button to the user. Thus we have buttons which cannot provide their expected functionality. If I run the Corona sample app when I have the Facebook App installed, the “logout” button does absolutely nothing. I’m still able to post messages after pressing “logout”. This is a bad user experience. [import]uid: 103727 topic_id: 26868 reply_id: 109443[/import]

I’d appreciate an answer to this question. [import]uid: 112085 topic_id: 26868 reply_id: 112763[/import]

Please, can you tell me how do you have cofigured your facebook APP??

Clave Hash de Android:

Android Package Name:

Android Class Name:

And if you have created a HASH key, how do you have created one? O.o
[import]uid: 153233 topic_id: 26868 reply_id: 112764[/import]

Buzz,

You still need to perform a login in your app regardless if the Facebook app is installed or not. The login is needed to request an oauth token from Facebook. If the Facebook app is installed, then the oauth token is retrieved from the Facebook app after it authenticates the user. If the Facebook app is not installed, then this is done via a web popup. Both behavior are automatically handled by the official Facebook SDK that we use… which in turn does not tell us if the Facebook app is installed either.

Corona does automatically save the received oauth token and look at its expiration date for you. So, if you login and the previous oauth token has not expired, then it will re-use it and avoid displaying the login window.

Now, my recommendation is to not display a Login button. Instead, just go ahead and provide the facebook functionality in your app, such as posting messages. When the end-user attempts to post a message, go ahead and attempt a facebook login first, regardless if it has already been done or not. The facebook login will automatically check if the app already has an oauth token and if it has expired or not. If the current oauth token is good, the login will do nothing and just return a success result to your Lua listener, in which case go ahead and post a facebook message from within that listener. If the oauth token is missing or expired, then the facebook login will prompt the user to re-sign in or attempt single sign-on with the installed facebook app, fetch the oauth token, and return the result of the login (success/fail) to your Lua listener… where you would then post the facebook message if the login succeeded.

So, the work-flow looks like this…

  • facebook.login() ->
  • facebook Lua listener is called ->
  • post facebook message IF login succeeded

Do the above ever time, even if you have already logged the user in. Does that make sense? [import]uid: 32256 topic_id: 26868 reply_id: 112832[/import]

Alberto,

Instruction for setting up your app on Facebook’s website can be found here…
http://developers.facebook.com/docs/mobile/android/build/

We also have a sample app “Networking\Facebook” that is included with the Corona SDK that demonstrates how to use Corona’s facebook API. [import]uid: 32256 topic_id: 26868 reply_id: 112833[/import]

Joshua thank you…

I seen the demo, but when i try to use in facebook nothing happend…

I solved the problem following the link and SIGNIGN my application :slight_smile:

Thank you :wink: [import]uid: 153233 topic_id: 26868 reply_id: 112893[/import]

Glad you got it working!

And don’t feel bad if it was giving you trouble at first. A lot of Android developers (not just Corona developers, but the Java programmers too) have struggled to get Facebook support working at first. By far the most common issue is developers entering the wrong hash code for their app onto Facebook’s website. [import]uid: 32256 topic_id: 26868 reply_id: 113077[/import]

Joshua, that makes sense. Thank you for explaining that. [import]uid: 103727 topic_id: 26868 reply_id: 113104[/import]