iOS 上的 com.facebook.sdk 错误 2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14159965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 21:44:04  来源:igfitidea点击:

com.facebook.sdk error 2 on iOS

iosfacebookcordovaphonegap-pluginsfacebook-ios-sdk

提问by saltandpepper

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.

我有一个可以在 iOS 和 Android 上运行的 Phonegap 应用程序。该应用程序具有 Facebook 登录功能,该功能直到几天前才有效。我们的一些 Beta 测试人员报告了“无法完成操作 com.facebook.sdk 错误 2”错误。这些测试人员的设备各不相同:iPhone 5、iPhone 4s、iPod Touch、iOS 5.1.1 和 iOS 6.0。

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

我们使用最新的 Facebook SDK 和 Phonegap Facebook 登录插件 ( 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).
  • 我的 info.plist 文件中的 BundleIdentifier 和 BundleURLName 与我的 Facebook 应用程序设置中本机 iOS 应用程序下的 Bundle ID 不匹配。
  • 该应用程序仍处于沙盒模式
  • 该应用程序在 Facebook 设置(设备设置 -> Facebook -> 允许这些应用程序使用您的帐户)中被禁用。
  • iOS 6.0 不允许同时询问读写权限(不确定我是否有这个权利)。

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).

这是一个非常不一致的错误(就我而言)。如果我在“允许这些应用程序使用您的帐户”中关闭应用程序(在我的情况下应用程序列在那里),我只能自己重现错误,但我可以通过再次允许应用程序轻松修复错误。目前大多数测试人员没有这个错误(不再),但错误仍然存​​在于 iPod 上(该应用程序也未列在“允许这些应用程序使用您的帐户”中)。

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

有谁知道我为什么会有这个错误?

采纳答案by saltandpepper

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.

事实证明:com.facebook.sdk 错误 2 可以转化为很多东西。我正在寻找某种 Facebook SDK 错误转换表,但找不到。就我而言: 由于连接超时,发生了 com.facebook.sdk 错误 2。收到此错误的用户的网络/WiFi 连接不良

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.

我们实施了一个错误日志系统,它会在每次登录 Facebook 时发生错误时记录错误详细信息。在这些日志中,我们可以看到 com.facebook.sdk 错误 2 经常发生,但每次用户在几秒钟后尝试再次登录时都会解决。

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.

这可能是因为我无法找到正确的文档,但我曾经并且仍然对这些 SDK 错误的模糊性感到非常沮丧。有很多关于权限请求的文档(这可能导致 com.facebook.sdk 错误 2),但显然这个错误可能是由更多的事情引起的。很高兴在某处看到这个记录。

回答by seans23

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."

这发生在我正在使用的应用程序中。我可以通过转到我的 iPhone 设置,选择 Facebook,点击我的名字,然后单击“删除帐户”来绕过它。

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

之后,我可以毫无问题地使用该应用程序登录。

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

我回到设置| facebook 并重新提交了我的凭据。

The app still works fine.

该应用程序仍然可以正常工作。

回答by coolcool1994

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.

当我忘记检查 Native iOS App(在 Facebook Developers Page 中)并输入我的 Bundle ID(与您的 Xcode 项目中的 Bundle identifier 相同)时,我遇到了这个错误。(包括最后的项目名称。)我还在 Facebook 开发者页面中设置了启用 SandBox 模式的设置。我也禁用了沙盒模式来完成这项工作。

回答by kokoko

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 FBSessionDefaultAudiencefor FBSession(was testing at 6.0+ and native facebook api gave me an error reason). And when I used

很长一段时间以来,我一直在弄清楚这个错误的原因,因为我使用旧的 iOS 5.0 来覆盖更大的设备。我刚刚通过 facebook 请求调试收到错误 400。所以最后,我想通了,原因是未知FBSessionDefaultAudienceFBSession(在6.0以上和原生的Facebook API正在测试给了我一个错误的理由)。当我使用

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

this error finally dissappeared.

这个错误终于消失了。

回答by Kyle Clegg

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.

这对我有用,并且不需要我实际删除 fb 帐户并按照@seans23 的建议重新登录。如果它不起作用,我接下来会尝试这样做,但这显然在重置状态方面确实存在技巧。

回答by Teodor Ciuraru

This approach worked for me. (iOS 8)

这种方法对我有用。(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.
  • FB“登录”按钮未在 Safari 中打开 FB 应用程序或 FB
  • 弹出 FB SDK 错误。2.
  • “我的应用程序”未显示在 FB 设置中以便启用使用。

The solution:

解决方案:

  • Clear Safari Web Cache (it may be optional)
  • Remove Facebook app
  • Remove Facebook Messenger
  • Install your app and log in
  • 清除 Safari Web 缓存(它可能是可选的)
  • 删除 Facebook 应用
  • 删除 Facebook Messenger
  • 安装您的应用程序并登录

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

这个想法是消除双方Facebook的应用程序和使者。

回答by kalafun

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!

对我来说,原因是我在模拟器上测试我的应用程序。我想分享一张照片,但对话框没有出现,所以我插入了我的 iPhone,之后一切都很顺利!

回答by Milos Djikic

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.

我们有同样的问题。事实证明,原因确实是在 FB 端超时,特别是如果在“FB 登录”页面仍然打开时发生此超时,并且用户单击“取消”。在这种情况下,总是重新调整错误 2。因此,如果您想重复并测试这种情况,只需在连接 FB 时单击“取消”按钮即可。

回答by Felipe

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.

干杯。