32

I have a Phonegap app that runs on both iOS and Android. The app has a Facebook login feature which worked until a few days ago. A few of our beta testers have reported an 'The operation couldn't be completed com.facebook.sdk error 2' error. The devices of these testers vary: iPhone 5, iPhone 4s, iPod Touch, iOS 5.1.1 and iOS 6.0.

We use the latest Facebook SDK and a Phonegap Facebook login plugin (https://github.com/davejohnson/phonegap-plugin-facebook-connect/).

I've done some research and found the following reasons why this error could occur:

  • BundleIdentifier and BundleURLName in my info.plist file don't match the Bundle ID under Native iOS app in the settings of my Facebook app.
  • The app is still in Sandbox mode
  • The app is disabled in the Facebook Settings (device's settings -> Facebook -> Allow These Apps To Use Your Account).
  • iOS 6.0 doesn't allow for the asking of read and write permissions at the same time (not sure if I have this right).

The following is the case:

It's a very inconsistent bug (in my case). I can only reproduce the error myself if I switch off the app in 'Allow These Apps To Use Your Account' (in my case the app is listed there), but I can easily fix the error by allowing the app again. At the moment most of the testers don't have this bug (anymore), but the error remains on an iPod (where the app isn't listed in 'Allow These Apps To Use Your Account' either).

Does anyone have any idea why I'm having this bug?

saltandpepper
  • 878
  • 2
  • 10
  • 29
  • 1
    This usually happens with oAuth failures. Does it happen only when you're requesting read permissions or write permissions. I hope you're not requesting them both at the same time. Also does it fail only on auth using Facebook app or iOS6 native settings or m-site. – Shireesh Asthana Jan 05 '13 at 06:05
  • No, I am not asking for read and publish permissions at the same time. I'm not sure about the second question. How can I find this out? – saltandpepper Jan 23 '13 at 13:03

9 Answers9

17

Turns out: a com.facebook.sdk error 2 can translate into a number of things. I'm looking for some kind of Facebook SDK error translation table, but I'm unable to find one. In my case: The com.facebook.sdk error 2 happened because the connection timed out. Users who got this error had a bad network/WiFi connection.

We implemented an error logging system, which logged the error details every time an error happened while logging into Facebook. In those logs we could see a com.facebook.sdk error 2 happening quite a lot, but it being resolved every time the user tried to log in again after a few seconds.

It might be due to my inability to find the right documentation, but I was and still am quite frustrated about the vagueness of these SDK errors. There is a lot of documentation about permission asking (which can result into the com.facebook.sdk error 2), but apparently this error can be caused by more things. It would be nice to see this documented somewhere as well.

saltandpepper
  • 878
  • 2
  • 10
  • 29
  • 2
    It looks to me like the FBError.h file contains the enum that defines the Facebook Error codes, and the error identifier that corresponds to 2 is FBErrorLoginFailedOrCancelled. – devdavid May 15 '13 at 18:44
  • 1
    Well, that's some clarification. But still, what causes a 'FBErrorLoginFailedOrCancelled' error? It's still very general and doesn't say anything about what causes that error. So I'm still of the opinion that accompanying documentation is needed to find the source of these errors. – saltandpepper May 17 '13 at 09:37
  • 7
    In my case, this error happened because the app was in Sandbox mode, and the test account I was using wasn't a developer or admin of the app. – Andrew Church Jul 13 '13 at 16:03
6

This happened for an app that I was using. I was able to get around it by going to my iPhone settings, selecting Facebook, tapping on my name, and clicking "delete account."

Afterwards I was able to sign in with the app without issue.

I went back to settings | facebook and resubmitted my credentials.

The app still works fine.

seans23
  • 116
  • 1
  • 3
  • This took me the best part of 5 hours. Cheers mate. The crap thing is, is that it isn't even a 'proper' fix so I still have no idea how to deal with this in code. Thanks for solving a big part of the headache at least buddy! :) – SparkyRobinson Nov 21 '14 at 12:37
5

I had this bug when I forgot to check Native iOS App (in Facebook Developers Page) and typed-in my Bundle ID, which is same as Bundle identifier in your Xcode project. (including your project name at the end.) I also had the setting in Facebook Developers Page which enabled SandBox mode. I disabled Sandbox mode too to get this work.

coolcool1994
  • 3,085
  • 3
  • 32
  • 38
4

I was figuring out the reason of this error for a long time as far as I work with old iOS 5.0 for bigger devices coverage. I've just recieved error 400 through facebook request debug. So finally, I figured out that the reason was in unknown FBSessionDefaultAudience for FBSession (was testing at 6.0+ and native facebook api gave me an error reason). And when I used

+ (BOOL)openActiveSessionWithPublishPermissions:(NSArray*)publishPermissions
                                defaultAudience:(FBSessionDefaultAudience)defaultAudience
                                   allowLoginUI:(BOOL)allowLoginUI
                              completionHandler:(FBSessionStateHandler)handler;

this error finally dissappeared.

kokoko
  • 2,614
  • 3
  • 15
  • 25
1

TRY FIRST:

Go to Settings app -> Facebook -> Your App -> Switch it off and back on again.

This worked for me, and didn't require me to actually delete the fb account and log back in as @seans23 suggests. If it hadn't worked, I would've tried that next, but this apparently did trick in resetting the state.

Kyle Clegg
  • 36,212
  • 26
  • 127
  • 138
1

This approach worked for me. (iOS 8)

The context:

  • FB "Log in" button didn't open FB app nor FB in Safari
  • Popped FB SDK err. 2.
  • "My App" wasn't showed in the FB Settings in order to be enabled for use.

The solution:

  • Clear Safari Web Cache (it may be optional)
  • Remove Facebook app
  • Remove Facebook Messenger
  • Install your app and log in

The idea is to remove both the Facebook App and the Messenger.

Teodor Ciuraru
  • 2,949
  • 1
  • 27
  • 33
1

For me the reason was that I was testing my app on simulator. I wanted to share a photo and the dialog just didn't come up so I plugged in my iPhone and everything went smoothly afterwards!

kalafun
  • 3,032
  • 5
  • 33
  • 47
  • What I've learned from this thread is that error 2 can mean just about anything. This was the cause in my case, too. Interestingly I am able to log in, but encounter this error attempting to share. – Robert Sep 09 '16 at 18:30
0

we had the same issue. As it turns out, reason is really in timeout on FB side, and especially if this timeout occurs while "FB login" page is still on, and user clicks on "cancel". In that case, error 2 is always retuned. So, if you want to repeat and test this situation, just click on "cancel" button while connecting on FB.

0

In my case I created the app with my companies account and forgot to add my personal profile with a Developer Role. After I figured that out everything went smoothly.

Cheers.

Felipe
  • 460
  • 9
  • 28