com.facebook.sdk error 2 on iOS

不想你离开。 提交于 2019-11-27 21:51:12

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.

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.

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.

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.

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.

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.

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!

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.

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.

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