The data browser is built for Chrome, Firefox, Safari, and IE9 and above. Please upgrade your browser, or download Google Chrome to get the best experience.
Back to Questions

Parse + FB + iOS6 = login not working?

12 votes     9 answers     19.8k views     

6

Right, after some further research and a heads-up from David, here's what could be wrong:

1) Facebook 3.1 SDK splits read and publish permissions. Use only read permissions (e.g., email) in the first authentication call. Using both will break it and result in that generic error. It seems Facebook's SDK doesn't actually do what it's meant to do: fall back to older authentication methods. David tells me an updated Parse SDK will make the permissions split easier, but it will of course be up to Facebook to fix that bug in their SDK.

2) Independently, the issue I was having seems to have gone away after signing out of Facebook in the device's Settings, and then back in. Maybe a glitch in the iOS integration? (The permissions split issue still applies here, however. Make sure you do read first and publish (e.g., publish_actions) separately later, the first time you actually need it.)

The new 1.1.10 iOS SDK is now available.

- Héctor Ramos over 1 year ago

Still cannot get this to work with Parse 1.1.10

Using [PFFacebookUtils logInWithPermissions:permissions block:

tried diff values for permissions inc @"user_about_me" or @"email". No write permissions requested.

If device is signed into FB Account in: Settings | Facebook, then [PFFacebookUtils logInWithPermissions] always returns:

Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x2086d350 {com.facebook.sdk:ErrorInnerErrorKey=Error Domain=com.apple.accounts Code=7 "The operation couldn’t be completed. (com.apple.accounts error 7.)"}

- Andy Jordan over 1 year ago

If FB not configured in Settings | Facebook then fb requests app authorisation & [PFFacebookUtils logInWithPermissions] completes as expected.

- Andy Jordan over 1 year ago

Have you tried signing back into Facebook in Settings, after having signed out? If that doesn't help, then I'm not sure what it could be apart from a bug in iOS and/or Facebook itself.

- Nikita Logachev over 1 year ago

And have you tried deleting+reinstalling the app? The more scenarios we understand the better.

- Nikita Logachev over 1 year ago

Did a bunch of things. Not quite sure what fixed it, but: 1) Updated to 1.1.10 SDK 2) Made sure I had my bundle id on https://developers.facebook.com/apps set 3) Added my facebookid to my .plist - at this point it still didn't login 4) Went to my settings and saw that my App had "Allow These Apps to Use Your Account" set to off. I turned it on (I did not logout/delete fb settings on my phone). Next time I logged in to fb on the app it worked

Not sure what exactly made it work but at the start I was getting the same sdk error as others, but now it works. Hope this helps.

- Matt over 1 year ago

For those reading this and still having issues, make sure you have added both app id configurations in your plist file. Before 3.1, there was the standard URL scheme addition. Now there's the FacebookAppId entry. The old is is still required and is in the form ' fb<followed_by_your_app_id> ' and the new one is simply the strong value of your app id (no prefix). Check here, the very last part in 'Configure a new XCode Project': https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/

- Nikita Logachev over 1 year ago

OK. Partly my fault but still have a problem. A @"offline_access" had sneaked into my logInWithPermissions. If I remove this and only retain @"user_about_me" in my login this error goes away. Other problem is better described in the existing thread, here: https://www.parse.com/questions/facebook-login-error-validating-access-token-simulator-vs-device-issue

- Andy Jordan over 1 year ago

still not working. you have to do?

- JhonGrim over 1 year ago

Yep my issue was the same as Andy's. After removing offline_access from the initial permission now it works fine. So thank you Andy for finding that!

- Bora over 1 year ago

I have additional findings that may help. It looks like even when the settings are all correct, this error may pop up. "To fix this: 1) Go to Facebook and delete your app 2) Switch on the permission for your app in your iPhone Facebook settings 3) Come back and retry." Strange...

- Bora over 1 year ago

and I'll tell probare. Thanks

- JhonGrim over 1 year ago
4

It looks like there's a new requirement in iOS 6 apps that might be causing this issue -- you need to make sure your "Bundle ID" is set correctly on your Facebook app's settings page (https://developers.facebook.com/apps/).

If you're still seeing this issue after verifying that your bundle identifier is set, please send an email to feedback@parse.com and we'll work with you to try and figure out what's going on.

My bundle ID is set correctly and I still can't login. Have send you an email.

- Kasper Pihl Tornøe over 1 year ago

Same here. Set the bundle ID in an attempt to fix it - no luck.

- Nikita Logachev over 1 year ago

I have the same problem. Email sent.

- Andy Jordan over 1 year ago

I'm not even seeing an option to enter a "Bundle ID" in my Facebook dev page.

- Tim Arnold over 1 year ago

aha, update: My app wasn't enabled as a "Native iOS App", and thus that option was not appearing. Thanks to George Deglin below.

- Tim Arnold over 1 year ago

A lot of these issues can be avoided by following Facebook's own tutorials on getting started with iOS. :)

- Nikita Logachev over 1 year ago

Nikita Logachev: good point. I think one reason, for me, that some of these issues were confusing was that I had a previously functioning Facebook SDK + iOS app, and upgrading to the latest Facebook SDK broke things.

- Tim Arnold over 1 year ago

"I know that feel bro" ;)

- Nikita Logachev over 1 year ago
3

I have the same problem, it looks like the problem is the build in Accounts stuff. I get the following error when trying to log in from iOS 6. It works perfectly when facebook login is going through safari or facebook app.

Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x1c5cb9c0 {com.facebook.sdk:ErrorInnerErrorKey=Error Domain=com.apple.accounts Code=7 "The operation couldn’t be completed. (com.apple.accounts error 7.)"}

And have btw given permissions in facebook settings to allow my application

- Kasper Pihl Tornøe over 1 year ago

We saw the same thing: manually allowing the application in Facebook settings on the iOS6 device didn't solve the problem. Could something have been overlooked in the Facebook SDK 3.1 integration? They changed the session workflow, separating read/write permissions, etc. Could this be the cause?

- Nikita Logachev over 1 year ago

The new 1.1.10 iOS SDK is now available.

- Héctor Ramos over 1 year ago
3

Any solution so far? I'm using the latest (v1.1.15) and Parse's own sample app https://github.com/ParsePlatform/IntegratingFacebookTutorial

I changed this sample's bundleId match my FB app, and I got the error:

IntegratingFacebookTutorial[7439:907] Uh oh. An error occurred: Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x1e58c4f0 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorLoginFailedReason}

3

I was having the same, or a similar issue. I believe I was able to fix it by going into the Facebook application settings (https://developers.facebook.com/apps), then enabling "Native iOS App", then finally setting the Bundle ID.

2

I think I may have found a key part of the problem. It seems that, on IOS 6 with Facebook 3.1 and Parse (and using the Parse Login/Signup Controllers), the magic that doesn't seem to happen is the critical call to:

pseudocode:
     [ACAccountStore requestAccessToAccountsWithType:facebookType 
          options:@{ACFacebookAppIdKey:FACEBOOK_APP_ID} completion:...]

Ideally in the Login and Signup controllers there would be a callback that gets fired before a user tries to either signup with or login through Facebook. At this point, we can make sure the IOS 6 stuff is handled.

Failing this, I don't see a logical place to inject this logic. As it stands this is an all or nothing. Using the ParseLogin/Signup Controllers you have to make the IOS6 auth call no matter that the user will/will not be using Facebook to sign in/up.

This tight-but-opaque integration is really not ideal and might I suggest that you open source just the Login and Signup Controllers as the community could probably have already fixed this for you.

Hope this helps out.

Just a note that if this is indeed the issue, using login methods directly without the view controllers is no longer an issue.

- Nikita Logachev over 1 year ago

I am using the login method directly. But when I alter request publish permissions, facebook goes into quick switching mode rather than using native Facebook.

- Andy Jordan over 1 year ago

which permissions are you using in the method?

- Nikita Logachev over 1 year ago

and which login method are you using?

- Nikita Logachev over 1 year ago

Method:[PFFacebookUtils logInWithPermissions..... and Permissions: @"user_about_me"

- Andy Jordan over 1 year ago

That works fine in our case. You're signed in to Facebook in the device's Settings and the app is 'allowed'? It would fallback to fast switching if either of those isn't the case.

- Nikita Logachev over 1 year ago

Hi Nikita, What works fine in your case? From my earlier comment: Login works for me once I removed @"offline_access" from permissions. BUT it then falls back to fast switching if I later request publish permissions [PF_FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]. I wonder if you would mind trying that to see if you get fast switching or native at that that point. Thanks

- Andy Jordan over 1 year ago

I get fast-switching at that point. As far as I can tell, native login is just that - login. Along with read-permission-based info I may be wrong.

- Nikita Logachev over 1 year ago

I think it applies to more than that. For example: "You should see the permissions dialog or permissions alert (iOS6+) asking for publish permissions." from https://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/. Maybe I've misunderstood it but I thought the whole point was to avoid fast switching.

- Andy Jordan over 1 year ago

Another thread https://www.parse.com/questions/facebook-ios6-native-dialogs-problem where native dialogs don't work after [PFFacebookUtils logInWithPermissions...

- Andy Jordan over 1 year ago

You're right... I've sent David an email about this. Not sure if it's Parse or Facebook itself though.

- Nikita Logachev over 1 year ago

Thanks Nikita, I think David is aware of this. He mailed a link to Fb 3.1.1 updates and I can see from the latest Parse release that he's put back these updates. I'll be testing the latest version soon. Thanks.

- Andy Jordan over 1 year ago

This is fixed for me using [PFFacebookUtils logInWithPermissions and Parse SDK 1.1.12

- Andy Jordan over 1 year ago

Using [PFFacebookUtils logInWithPermissions] and Parse SDK 1.1.12 still can't get it to work. Check the bundle IDs and set the right AppId in the plist and in the URL scheme.

When I install the app it is added to the list of Facebook apps under General Privacy screen in the iPhone. But the app is by default not granted access. So when using loginWithPermissions it should popup the dialog to give acces or not....

- aFrogLeap.com over 1 year ago

@Joe tried deleting the app from your Facebook settings and then reinstalling and trying again? :)

- Nikita Logachev over 1 year ago
1

So, adding to my previous, here's a hacky partial workaround. In a subclass of PFLoginViewController:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        __block BOOL fbEnabled = YES;
        if([SLComposeViewController class]){
            if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(OK_IOS_6_0)){ 

                ACAccountStore *store = [[[ACAccountStore alloc] init] autorelease];
                ACAccountType *facebookType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
                ACAccount *fbAccount = [[store accountsWithAccountType:facebookType] objectAtIndex:0];

                if(fbAccount){
                    [store requestAccessToAccountsWithType:facebookType
                                                   options:@{ACFacebookAppIdKey:FACEBOOK_APP_ID}
                                                completion:^(BOOL granted, NSError *error) {
                                                    if(error){
                                                        DDLogError(@"ERR %@/%@ %@", THIS_FILE, THIS_METHOD, error);
                                                    }
                                                    if(granted == NO){
                                                        fbEnabled = NO;
                                                    }
                                                }];
                }
            }
        }
        NSUInteger fieldsMask = PFLogInFieldsDefault | PFLogInFieldsDismissButton;
        if(fbEnabled) fieldsMask |= PFLogInFieldsFacebook;
        [self setFields: fieldsMask];

    }
    return self;
}

You can't seem to change the fields in the viewDidLoad so once it's set it's set.

Also note this will not run out of the box as the SYSTEM_VERSION_IS_GREATER_THAN_OR_EQUAL_TO is a custom macro and DDLogError can just be replaced with NSLog.

Thanks for this. I'll try this code in the morning. In my case I'm not using PFLoginViewController for Facebook login but [PFFacebookUtils logInWithPermissions:block:]; in a utility class.

- Andy Jordan over 1 year ago

I think the key is to ask the ACAccountStore for permission first. It seems that Facebook is interacting with it and if you don't ask first Facebook doesn't recover gracefully. It's really a case of too many moving parts without enough transparency into what's going on in everyone's black box. ugh!

- Michael Bishop over 1 year ago
1

Solving the fast-switching problem when posting: I have found a temp sloppy workaround that has worked for me. This solved that I was getting fast-switching for every post when the app restarted and was running based on parse prelogin. This did not happen if you logged out and back in once in the app. So I did the obvious workaround, I set it up do that FB would log in and out on startup and it fixed the problem. It does seem that parse is missing something when reauthorizing.

Sloppy workaround:

//verify logged in with FB & Parse
if ([PFUser currentUser] && [PFFacebookUtils isLinkedWithUser:[PFUser currentUser]])
    {
        //log out
        [PFUser logOut];

        //log back in
        NSArray *permissionsArray =  [NSArray arrayWithObjects:nil];
        [PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error)
     {
        //verify…
        }];
    }

This is dirty but after a lot of trile and error it got the job done at no apparent performance hit. Still more testing to be done but this is working for now.

hi andree canella ,

  this is chiranjeevi , i working on Facebook integration to iPhone  using parse.com its to complicated can you  give a correct solution  actually before in my apps i didn't work on that thats why i get a confuse on that .i f u have time place send me code for 

1.facebookconnect 2.registration 3.loing and forgot password. and my mail id is ios1552@gmail.com

- chiranjeevimacharla over 1 year ago
1

The integration is driving me crazy. I've gotten it to work for maybe 80% of cases but there are consistent, reproducible (of course not on any of my devices!) instances, particularly with IOS 6 where either the Parse magic or the Facebook SDK is failing on login.

Has anyone gotten the Parse-Facebook login to work 100% of the time? I've seen many parse updates since this first appeared, none of which mention Facebook which makes me curious if there are instances where this is working fine and I'm doing something wrong.

It seems possible that there's at least one case which may not be under your (or Parse's) control, because it may be a bug in iOS itself. From what I gather, the Facebook deep integration in iOS can fail under specific conditions and you'll see the mysterious error 2 (or 5 even?).

- Nikita Logachev over 1 year ago

That's what I was afraid of. Wonder if this has been reported to Apple? Surely someone has already done so?

- Michael Bishop over 1 year ago

You're not alone. I see the FB connection error from our users every now and then. This wasn't happening at all before the native implementation. Sometimes if you try a few times then it works. I have several users who are unable to connect their Facebook accounts right now.

Here is the awesomely descriptive error:

Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed. (com.facebook.sdk error 2.)" UserInfo=0x1e958af0 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorLoginFailedReason}

- Bora over 1 year ago

And the weird thing is that I've managed to get rid of the error before by deleting the app from my personal Facebook settings, reinstalling and logging in. Error before that, fixed after that.

- Nikita Logachev over 1 year ago

Yeah a mysterious combination of delete, reinstall, log out, log in, delete permission from FB etc sometimes "may" work but can we ask our users to do things like that? Heck no. So it should just work all the time. So weird. I'm paranoid about this now. Even thinking about rolling back to non-native way since that just works.

- Bora over 1 year ago

@Bora: Yeah, that's the one! @Nikita: ditto that, I've been able in some instances been able to fix by deleting. It's maddening all the different edge "fixes" that work only for a slice of those getting errors. The resulting spaghetti code of 'fixes' is ridiculous given the supposedly few lines of code you're supposed to need.

@Nikita: Any chance that we can get a flag in parse to use the old Facebook sdk only until this gets worked out? Seems the source of this is Apple's half-baked implementation and at this point, I'd rather just do it the long way but I don'd really want to manage FB and Parse as separate entities.

- Michael Bishop over 1 year ago

@Bora its a mess. If you have a choice the old way is the only way to make it work consistently.

- Michael Bishop over 1 year ago

I had a look at Facebook's bug section and iOS6-related login bugs are definitely popping up. Hopefully this mess will be ironed out sooner rather than later. iOS6.1 beta has been seeded (as you all probably know already).

@Bora - that's a question for the Parse team. ;) An alternative is that if the fallback to fast-switching works for you (and it should with the latest version as far as I remember), login with both read and write permissions. It's a bit hackish, but it will force the SDK not to use iOS6 native login.

BTW, I'm not sure if some of you here are assuming that I'm associated with Parse... I'm not. :)

- Nikita Logachev over 1 year ago

@Nikita sorry about that, you're so active here I thought for sure worked for Parse! :)

- Michael Bishop over 1 year ago

So did a fix ever get ironed out for this bug?

- Chase over 1 year ago