Facebook login on iOS always cancels the very first login attempt

Ajay told me yesterday that the current non-V4 plugin should be using 2.1 endpoints.

The Facebook SDK changelog for version 3.17 is where they started targeting Graph API v2.1:

iOS changelog: https://developers.facebook.com/docs/ios/change-log-3.x

Android changelog: https://developers.facebook.com/docs/android/change-log-3.x

The old Facebook plugin currently uses Facebook SDK 3.19 on iOS and 3.18 on Android.

Hi there,

Any news for the bugs with plugin facebook v4 with iOS9.

Thanks so much!!! 

I don’t have any more news other than we are trying to find the problem.

Rob

So as to not continue hijacking this thread from login problems, can we continue the discussion about the Graph API 2.0 email warnings on this thread:

https://forums.coronalabs.com/topic/63786-graph-api-v21-upgrade-notice/

Thanks

Rob

Now that the latest public build has been released, I just wondered if there is a rough ETA regarding the v4 login issues?

I know they are working on it.

Rob

Ok that’s great. I knew it was on the radar, but wasn’t sure how long after the public build it would be before it was being worked on. Thanks for the update.

Hi there,

Any news for the bugs with plugin facebook v4 with iOS9.

Thanks so much!!! 

For iOS make sure you have set the Client Token in the FB Developer control panel:  https://developers.facebook.com Go to your app’s settings open the advanced tab and reset the client token.

That seemed to be a fix for my test app. But on Android we are still exploring the cause.

Rob

In fact, i have no issues with facebook_v4 on Android. 

What are those issues ??

It appears to be some setup issue that’s causing the problem, we just don’t know what it is yet so not every developer will experience it. For instance the engineer working on it, when he uses his Facebook app, works like a charm, when he hits my Facebook app, it fails.

The investigation continues. 

Hi guys,

I may have found a fix for this problem. First of all: the problem only affects some facebook accounts. One of my test accounts is working fine while the other one fails every time.

I am using latest public release 2907 and official facebook example.

First login attempt works fine for me, but the second one, the one you trigger by clicking “Get User” button, always fails with loginCancelled event.

I simply patch enforceLogin() function as follows:

local function enforceFacebookLogin( ) if facebook.isActive then local accessToken = facebook.getCurrentAccessToken() if accessToken == nil then print( "Need to log in" ) facebook.logout() -- PATCHED CODE facebook.login( listener ) elseif not inTable( accessToken.grantedPermissions, "publish\_actions" ) then print( "Logged in, but need permissions" ) printTable( accessToken, "Access Token Data" ) facebook.logout() -- PATCHED CODE facebook.login( listener, {"publish\_actions"} ) else print( "Already logged in with needed permissions" ) printTable( accessToken, "Access Token Data" ) statusMessage.textObject.text = "login" processFBCommand() end else print( "Please wait for facebook to finish initializing before checking the current access token" ); end end

I inserted facebook.logout() statement just before facebook.login(…)

This change prevent loginCancelled event, and everything seems working fine. Please test and share your results.

I’ll give that a try, though I’m pretty sure I’ve already tried calling logout() and then login() again, as it was suggested by someone before (possibly on another forum post).

Hi guys,

For the iOS 9 and facebook v4 plugin, i have faced a new issue. 

I have created a new facebook app and try to login with the new app. Everything works fine.

But with the old one, it never login, the resonse is:

response_raw The operation couldn’t be completed. (com.facebook.sdk.login error 304.)

I have tried to reset the client token for the old facebook app however still cannot log in.

Same code, same plugin, same corona version with different facebook application id

Hi Rob, is there any more news on this login issue yet?

Using the sample app I no longer see this issue either on iOS or Android (login cancelled). And we’ve determined the cause (at least on Android, I’m still scratching my head why it went away on iOS)…

Any way, a few weeks ago, I update my app on Facebook’s developer portal to change my Client Token (under Settings->Advanced) and then iOS started working. But that didn’t do anything for Android. Using the sample app any thing after the first login attempt would result in a Login Cancelled.

My app was live on Facebook, but I never submitted it for review. The sample app was requesting the “publish_actions” permission which has to be approved by Facebook for live apps. Once I unpublished my app and put it back in testing mode, and using a test account, I can use the sample app with perfection with the exception of one of the dialogs which we know about and are working on.

The the gist of this is there are permissions like “publish_actions” which have to be approved by Facebook before you can use them in a “live” app. And in a non-live app, only listed testing accounts (and your admin account) can use the app.

The sample app always asks for “publish_actions” on subsequent logins but not the first login, which is why I was always getting a successful first run. If you’re asking for “publish_actions” in your first login, it’s going to fail if you’re not been approved by FB to use this on a live app.

Rob

@Rob; My facebook app has no client token set, and I am publishing this app for about 4 years without any problems.

What does client token do exactly?

I don’t know what it does. It doesn’t seem to impact the legacy Facebook plugin. The LoginCancelled feature seems to be something Facebook is doing in V4. I don’t know if it was the token or not, but before I set it, I was getting LoginCancelled on iOS after I set it, it seemed to work.

However I suspect its still has to do with my app being published/marked live without getting approval for “publish_actions” that was the real culprit.

Rob

Just wanted to add I’m having the same ‘loginCancelled’ issue on iOS. I have reset the client token, but no luck. I used to use the publish_actions permission which was approved previously, but I noticed today it was no longer approved. Since I don’t use it anymore I just removed the request by hitting ‘Start Over’ in Facebook’s settings.

Please let me know if there are any other suggestions. Running Corona SDK 2906.

UPDATE:

I can confirm the same code works 100% on android for logging into Facebook. This seems to be an iOS isolated issue.