FBSDK登录错误代码:Objective-C中的308

时间:2015-06-06 03:46:13

标签: ios facebook parse-platform facebook-sdk-4.0

我一直在

  

"错误域= com.facebook.sdk.login代码= 308"操作无法执行   完成。 (com.facebook.sdk.login错误308。)""

试图从我的设备登录Facebook时。

我的代码适用于模拟器,但不适用于实际设备。有没有人遇到过这个错误代码?我很乐意根据要求分享代码。

17 个答案:

答案 0 :(得分:49)

以下解决方案适用于在Xcode 8上运行的iOS9 +,适用于Swift3.0

步骤

  1. 设置Facebook发布
  2. FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

    1. 设置Open Url

      guard let source = options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String else { return false } let annotation = options[UIApplicationOpenURLOptionsAnnotationKey] as? String return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: source, annotation: annotation)

    2. 修复Keychain权限问题,如下图所示
    3. iOS 9 Keychain fix

答案 1 :(得分:42)

您应该在功能标签上启用钥匙串共享

答案 2 :(得分:26)

我遇到了完全相同的问题,并且能够通过修改Info.plist找到解决方案

我已将所有可能的方案添加到LSApplicationQueriesSchemes

完整列表如下所示:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2</string>
    <string>fb</string>
    <string>fb-messenger-api20140430</string>
    <string>fb-messenger-platform-20150128</string>
    <string>fb-messenger-platform-20150218</string>
    <string>fb-messenger-platform-20150305</string>
    <string>fb-messenger-api</string>
    <string>fbshareextension</string>
</array>

答案 3 :(得分:14)

我得到了完全相同的东西FB SDK 4.6.0 Xcode 7.0 iOS9。所有设置&amp;在Facebook开发者网站上的说明跟随信。 上述解决方案均不适合我。当您在执行登录过程时,实时部署到设备并反馈到Xcode控制台时,我发现行为更糟。如果它真的让你进入,它真的很好运。当您在部署后重新启动应用程序时,似乎以更可预测的方式运行。 - 事实上是这样的!

当它决定登录失败时,会导致以下错误:

Error Domain=com.facebook.sdk.login Code=308 "(null)"

答案 4 :(得分:5)

我在Xcode7.1上的解决方案,Swift2.0

步骤1.清理构建文件夹:option + command + K

或:选择Product&gt; Clean

enter image description here

步骤2.清理派生数据:选择Window&gt; Projectsenter image description here

然后选择Deleteenter image description here

答案 5 :(得分:4)

我遇到了同样的问题并修复了刷新系统凭据的问题

[FBSDKLoginManager renewSystemCredentials:^(ACAccountCredentialRenewResult result, NSError *error) {

    [[[YourAuthManager manager] facebookLoginManager] logInWithReadPermissions:@[@"email"] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {

        if (error) {
            // Handle error
        } else if (result.isCancelled) {
            // Handle cancellations
        } else {
            // If you ask for multiple permissions at once, you
            // should check if specific permissions missing
            if ([result.grantedPermissions containsObject:@"email"]) {
                // Do work
            }
        }
    }];
}];

此解决方案不如重新安装那么激进,您确保您的用户不必这样做。我的猜测是FBSDK 4.6与iOS 9系统FB身份验证凭据存在一些冲突。

编辑:经过一段时间的测试后,它不断发生,不像以前那样频繁,但仍然是一个问题,所以我们降级到以前版本的FB SDK。希望有人找到更好的解决方案。

答案 6 :(得分:4)

在FBs代码中进行了一些挖掘,看起来这只是一个权利问题。

FB使用钥匙串在登录期间存储授权质询。返回时,它尝试从钥匙串中获取值并失败。有关详细信息,请参阅this SO answer

安全权利可以在配置文件之间发生变化,众所周知,保持我们的配置文件和构建配置和设备/模拟器就像放牧猫一样。这可以解释为什么人们会遇到这种不一致的行为。

因此,可以安全地假设在生产环境中,一切都会正常工作,如果在测试过程中某些事情不起作用,那么您需要仔细检查配置文件中的权利。

答案 7 :(得分:1)

在我的情况下,通过更新到最新的FB SDK修复了它。 4.10目前。

答案 8 :(得分:0)

同样的问题FB SDK 4.5.1并没有上述解决方案适合我。 我通过拖动&amp; amp;添加了螺栓框架来解决这个问题。 drop(来自FacebookSDK目录)
然后将螺栓框架添加到appDelegate

    #import <bolts/bolts.h>

答案 9 :(得分:0)

我在xcode 7.1 ios 9.1 FB SDK 4.7.1上遇到了同样的错误。

第一次没有xcode的卸载,安装和测试工作正常。 这将允许您插回设备并至少运行几次(看起来有点不一致......)

答案 10 :(得分:0)

在FBSDKDelegate方法中loginButtonWillLogin把这个

- (BOOL) loginButtonWillLogin:(FBSDKLoginButton *)loginButton{
[FBSDKAccessToken setCurrentAccessToken:nil];
return YES;}

答案 11 :(得分:0)

更新到最新的(4.11)FB SDK也为我修复了这个问题。不要忘记在更新后清理你的项目,看看它是否适合你!

答案 12 :(得分:0)

通过添加新的plist键/值,我能够在iOS9上使用SDK 4.6.0再次登录

<key>FacebookDisplayName</key>
<string>{Your App Name}</string>

Source code

我还在这里采取了其他一些答案中的步骤来实现共享的FBSDKLoginManager()实例。

答案 13 :(得分:0)

我通过卸载应用程序并重新安装来修复此问题,并立即开始工作。

该错误可能与iOS 9有关。自iOS 9以来,我认为SDK使用了SafariViewController,并且在您已经登录时似乎会产生问题。

答案 14 :(得分:0)

To Resolve this issue you needs to just enable "Keychain Sharing" in capabilities.

答案 15 :(得分:0)

我跟随Suraj Pathak使用了 Xcode 9.4.1和Swift 4.2

  1. 添加到AppDelegate didFinishLaunchingWithOptions

    SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
    
  2. 添加到AppDelegate委托函数

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        return SDKApplicationDelegate.shared.application(app, open: url, options: options)
    }
    
  3. 允许使用功能性钥匙串。

答案 16 :(得分:0)

如果您使用的是FBSDK 4.38,则FBSDKLoginManager.m中的ChallengeExpected解析存在错误。

我找到了rinat-enikeev的修补程序:

https://github.com/facebook/facebook-sdk-swift/issues/286

https://github.com/facebook/facebook-objc-sdk/pull/922/commits/bcf7f787e92320a6322fb3f6130fdc3815bbafb7

只是改变

NSString *challengeExpected = [self loadExpectedChallenge];

NSString *challengeExpected = [[self loadExpectedChallenge] stringByReplacingOccurrencesOfString:@"+" withString:@" "];

那为我解决了这个问题。