com.facebook.sdk error 2 on iOS

隐身守侯 提交于 2019-12-28 05:56:28

问题


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:

  • The BundleIdentifier and BundleURLName match.
  • The app isn't in Sandbox mode.
  • The app doesn't appear in 'Allow These Apps To Use Your Account' of every user
  • The builders of the Phonegap plugin said to have fixed the iOS 6.0 permissions bug (https://github.com/davejohnson/phonegap-plugin-facebook-connect/pull/216)

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?


回答1:


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.




回答2:


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.




回答3:


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.




回答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.




回答5:


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.




回答6:


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.




回答7:


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!




回答8:


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.




回答9:


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.



来源:https://stackoverflow.com/questions/14159965/com-facebook-sdk-error-2-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!