Facebook permissions are acting up on Android.

So, my app is almost ready to be published both for Android and iOS, except for a small point. When ever I log in to Facebook api from my app on Android, it asks my permissions 3 times before it’s content to go on.

This does not happen in the iOS build, only on android, and it’s always 3 times before the Facebook API window is content and goes away, does anyone knows what is happening??

Thanks,

Yuval.

Hi Yuval,

Which build of Corona are you using?  Also, what version of Android are you running on your device, and is the Facebook app installed on the device?

  • Andrew

I’m using build number 2013.1232 (2013.10.9), I’m running android 4.1.2 on a Galaxy SIII, facebook app is not installed on my device, and never will be should I have a choice in the matter :slight_smile:

Thanks!

I’ve upgraded to build 2013.1257 (tried to the last build, the legacy one, but it had some problems, like asking for a password for the debug.keystone, which don’t have one, so that’s gone), and it still shows the same problem, on first Facebook log in, it asks me 3 times to authorize the app after log in, then it goes on normally.

Yuval.

Hi Yuval,

Can you post your code showing where you are calling facebook.login()?  Also, what permissions are you requesting from the user?  When you say that, on Android, it prompts the user 3 times for permission, is it asking for the same permission each time, or a different permission?

  • Andrew

I’m sorry if I was misunderstood, what happens is that the “popup” from the Facebook api, after I log in for the first time, asks me to authorize the app to use my Facebook account, or in my case, in tells me that the app is already authorized (since I’ve logged before), and I can choose “OK”, or “skip”, if I choose "OK, or “skip”, it does not matter, it popup the same api window telling my I have already authorized my app 3 times until it closes and goes away.

Yuval.

I even tried a mix of “OK”'s and "skip"s, but it’s the same, 3 “requests” of authorization telling me I’ve already authorized the app.

OK, I follow you.  Can you post the portion of your code where you call facebook.login()?  What permissions are you requesting?

  • Andrew

Yep, the code is:

if login\_data.type == 1 then       facebook.login(appId, facebook\_listener, {"publish\_stream", "email"}); elseif login\_data.type == 2 then       facebook.request("me/friends", "GET", {fields = "id,name,picture"}); end

Explanation:

If the user have not done a Facebook log in before, I do a log in, and in the response of the log in I would get the list I’m requesting here in the case the user have already done a Facebook log in, simple enough.

Right now I’m also trying to output to a debugger any response from the Facebook API so I would know if it’s not me making 3 calls, but the API acting up (my best clue so far is that it does not do this on the iOS version…).

And, as you can see, the permissions I’m asking for are “publish_stream” so I could post to friends wall, and “email”, so I could use it if the user chooses to do first log in to our app with his Facebook account instead of registering a “simple” account with our app.

Hope this helps, and I’ll get back to you with the results of my tests now to see I’m not over calling the API by some weird mistake that got in since the last version I compiled, which I don’t happens.

Yuval.

Ok, I’ve done 2 tests:

  1. checked the number of calls I make to the API when I need the information, after I authorized my app, and it’s 1 call, not 3.

  2. Removed the authorization to my app in my Facebook account, then did the re log, and request for friends list, this time, 2 calls, one for log in, one for list.

Result:

In both cases I was prompted for Authorizing my app 3 times before it went on.

Please note this happens only on the first time I use the Facebook API in my app, meaning the next time I’ll go into the part of the app that needs the list from Facebook, it will get it without prompt at all. Only if I uninstall the app, re install, and re request the information it will ask me 3 times to authorize the app.

Yuval.

Can you try deauthorizing your app from your Facebook account, then logging into it again?  I suspect that the 3 logins are related to the three permissions you’re requesting (basic_info, publish_stream, and email).  If the app isn’t authorized, I suspect the popups will ask for those three permissions one at a time.  If the app is already authorized, then the three popups are indicating that each permission is already authorized.

  • Andrew

Hey Andrew, a message above your, which you probably missed while writing your message, explains I’ve done just that, deauthorize the app, re logging, and exactly that happens, I make 2 call in total, 1 for the log in, once that is approved, 1 for the list of friend, yet still I’m being asked to authorize the app 3 times.

What I can do is remove the request for email, since I use that information only if I choose to register through Facebook, and see if I get only 2 times to Authorize instead of the 3.

Another problem I’ve just noticed, again, with Facebook, this time on iOS, is that if the Facebook app (may it burn in hell) is installed on the device, on the iPhone 4s, I have no problems with getting information from Facebook, while on the iPhone 5, the log in goes fine, but the request for information does not work, when I delete the Facebook app from the iPhone 5, it works just fine.

I’m still testing this problem to see what I do get, I’ll keep you updated.

Yuval.

OK, so the mail removal test was good, this time it asked me for the authorization only twice, not 3 times, so I guess your theory is correct, but why would it do that? and is there a way around it?

Yuval.

This is so frustrating!!

So on iPhone 4/4S with or without Facebook app installed, everything works fine, on iPhone 5, without Facebook app, works fine, with the Facebook app the Facebook API log in request pops up the APIs window, which closes by itself, since the device is already logged in, but the event listener does not fire at all!!

I hate face book so much… over so many years, working with anything related to Facebook was always a thorn in my ass, pardon my language… Anyone has any insight on this issue?

By the way, if I don’t have the Facebook app on the iPhone 5, I log in with my app to Facebook, it works ok, I ask for friends list, works ok, install the Facebook app, relaunch my app, ask for friends list again, works just fine, re install my app at this point, re log to Facebook, and nothing, listener is dead as a week old mouse in a trap.

Let me try to simplify the scenario to make sure I understand.  Launch the app for the first time and log in with facebook using facebook.login().  The facebook listener will fire.  Force quite the app and relaunch it.  If you call facebook.login() again, are you saying that the listener does not fire this time (on certain devices, namely your iPhone 5 when the Facebook app is installed)?

I haven’t experienced any issue like that.

  • Andrew

Nope, here it is broken down.

Case 1:

  1. Our suspect, an iPhone 5, clean, no FB app.

  2. Install my app, log in to it, do FB.login(), works.

  3. Ask friends list, works.

  4. Install FB app.

  5. Log out then in into my app, or remove and re install my app.

  6. Do FB.login(), works.

  7. Ask friends list, works.

JOY!

Case 2:

  1. Our suspect, an iPhone 5, with FB app.

  2. Install my app, log in to it, do FB.login(), DON’T WORK :frowning:

It would seems that if at some point you’ve logged into Facebook with my app before you had the FB app on it, there would be no problem to re log or request anything from the FB API, but once the FB is installed BEFORE you’ve logged in at least once with our app to Facebook, the listener we set up for Facebook event simply keeps quite.

And yes, it means if I have the phone with both the apps, both working, and I remove both of them, but then install FB App and log, then my app then log, and try FB.login() from my app, there is no response from the listener function, even though you can clearly see the FB API window popping up then off the screen.

Yuval @formatc, thank you for posting your finding.  

About Android version, my app does exactly the same (3 permission requests the first time the user log in to FB), and it’s been one of the most irritating things that I simply decided to ignore because it appears that’s the only workaround available with issues with FB integration.  (I don’t remember the URLs for the threads that articulated the issues that had to be resolved a while back.)

About iOS version, the issue with iPhone 5 does not sound very good at all.  What iOS version is installed on your iPhone 5?  I’m wondering if it’s the iOS version specific issue (rather than device type specific issue.)  Regardless, you may want to submit a bug report detailing this issue so that it will be addressed rather quickly.

Naomi

https://developers.facebook.com/docs/android/login-with-facebook/

When logging in to facebook with both read and publish permissions it asks you 3 times because thats how facebook wants it to be done.  The first time is for basic permissions, the second time is for read permissions, and the third time is for publish permissions.

If you call login without any permissions then it will just ask for basic permissions.  When you actually need read/publish permissions you can call login again with the new permissions then at that time it will ask the user again for those permissions.

Thank you, @dchan, for letting us know.  What I find odd is that the user experience is totally different between Android version and iOS version.  I wonder why Facebook enforces different permission mechanics.  The way FB allows iOS version to bring up  single popup for multiple permissions is much more elegant compared to, in our case, three permission requests popping up one after the other on Android version.  I totally don’t understand why they require user experience to be so different between Android and iOS when doing the same thing (i.e., logging in with permissions.)

Naomi

P.S.  @Yuval, I really do like to know if the iPhone 5 issue you described is something to do with iPhone 5 specific or iOS version specific.  What iOS version does your iPhone 5 have?  And what iOS versions does your iPhone 4 have?

Hi there Naomi, thanks for the information, it’s the first you’ve help cleared something up, so thanks again :slight_smile:

I will let you know the version of the iOS when I’ll have the device in my hands, a couple of hours from now, but I believe it’s 6.1, it wasn’t updated to 7 as far as I know, but I could be wrong.

I will try and change the app dynamics so it won’t request all permissions when doing log in, although I have no idea how it will act when I’ll try to publish, would it know by itself to ask permission or would I need to re log in with the requested permission for it to work? You’re on a completely different time zone then mine, so I guess I’ll just have to test this out to see, I hope this will work since I’m just about physically sick with working with Facebook, the source of all earthly evil.

Yuval.