Why am I getting com.facebook.sdk.login error 308?

核能气质少年 提交于 2019-12-02 17:09:40

For Xcode8 - iOS10,

Enable Keychain Sharing within Capabilities tab of target fixed my issue.

More details can be found here : https://github.com/facebook/facebook-sdk-swift/issues/51


For Xamarin Studio (Suggested by @Kenneth),

Add the Entitlements.plist file to Custom Entitlements under the iOS Bundle Signing options in the iOS project.

I found the solution to this problem. I was creating an instance of the login manager where i needed it:

let loginManager = FBSDKLoginManager()

Then i was using it to login and I was creating another instance in my logout method. I fixed the issue by creating a lazy variable to be used throughout the app:

lazy var fbLoginManager: FBSDKLoginManager = {
   return FBSDKLoginManager()
}()

UPDATE

Facebook are aware of the bug and are looking into it. I have found that my solution doesn't always work and have updated my code to the following and have not seen it since:

private var _fbLoginManager: FBSDKLoginManager?

var fbLoginManager: FBSDKLoginManager {
    get {
        if _fbLoginManager == nil {
            _fbLoginManager = FBSDKLoginManager()
        }
        return _fbLoginManager!
    }
}

When logging out of Facebook, you need to call _fbLoginManager = nil and the instance will be recreated when it is used to log in the next time. The issue seems to happen more often when using the same instance to log back in after logging out yet the issue happens even more when there are multiple instances of FBSDKLoginManager so declaring it as stated above seems to have fixed the issue.

October 2018.

Reason: "+" sign is replaced by " " in challengeReceived string. Issue in FBSDK.

Quick and dirty fix: https://github.com/facebook/facebook-objc-sdk/pull/922

Specifically, replace line 233 in FBSDKLoginManager:

NSString *challengeExpected = [self loadExpectedChallenge];

with

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

Looks like problem is solved with 4.9.0. I had the same problem and it's fixed with new SDK version.
https://developers.facebook.com/docs/ios/change-log-4.x

I also had this error the reason was in my case: AuthentificationController on which was Facebook login button was presented without navigation controller. To resolve this error i just added navigation controller and sat my AuthentificationController as root.

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