为什么会出现com.facebook.sdk.login错误308? [英] Why am I getting com.facebook.sdk.login error 308?

查看:278
本文介绍了为什么会出现com.facebook.sdk.login错误308?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 7.0,正在iOS 9.0.2上进行测试并使用Facebook SDK 4.7.0.

I am using Xcode 7.0, testing on iOS 9.0.2 and using Facebook SDK 4.7.0.

当我登录用户时,大多数情况下一切正常,但是有时我会不断收到此错误,我也不知道为什么!

When I am logging in a user, most of the time everything works as it should, however sometimes I keep getting this error and I have no idea why!

操作无法完成. (com.facebook.sdk.login错误308.)

The operation couldn’t be completed. (com.facebook.sdk.login error 308.)

经过研究,我发现有些人同时登录parse.com的FBUtils和官方的FBSDK时遇到错误,但是我在项目中仅使用FBSDK.

After researching I have seen that some people are getting the error when logging in with parse.com's FBUtils and the official FBSDK at the same time, however I am only using FBSDK in my project.

所以我的问题是,为什么我会收到此错误以及如何消除该错误?

So my question is, why am I getting this error and how do I get rid of it?

编辑-添加代码

这是我的登录逻辑:

func loginWithFacebook(sender: UIViewController, completion: (profile: FBSDKProfile?, token: String?, cancelled: Bool, error: String?) -> Void ) {

    FBSDKProfile.enableUpdatesOnAccessTokenChange(true)
    NSNotificationCenter.defaultCenter().addObserver( sender , selector: "onProfileUpdated:", name:FBSDKProfileDidChangeNotification, object: nil)
    let loginManager = FBSDKLoginManager()
    loginManager.logInWithReadPermissions(["email", "public_profile"], fromViewController: sender) { (result: FBSDKLoginManagerLoginResult!, error: NSError!) -> Void in
        if error != nil {
            print("ERROR")
            completion(profile: nil, token: nil, cancelled: false, error: error.localizedDescription)
            print(error.localizedDescription)

        } else if result.isCancelled {
            print("CANCELLED")
            completion(profile: nil, token: nil, cancelled: true, error: nil)

        } else {
            print("NO ERROR")
            if FBSDKProfile.currentProfile() == nil {
                print("PROFILE IS NIL")
                completion(profile: nil, token: result.token.tokenString, cancelled: false, error: nil)
            } else {
                print("PROFILE IS NOT NIL")
                completion(profile: FBSDKProfile.currentProfile(), token: result.token.tokenString, cancelled: false, error: nil)
            }

        }

    }
}

推荐答案

对于 Xcode8-iOS10

启用目标的功能"标签中的钥匙串共享已解决我的问题.

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

更多详细信息可以在这里找到: https://github.com/facebook/facebook-sdk- swift/issues/51

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

对于 Xamarin Studio (由@Kenneth建议),

For Xamarin Studio (Suggested by @Kenneth),

Entitlements.plist 文件添加到iOS项目中iOS Bundle Signing选项下的自定义权利中.

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

这篇关于为什么会出现com.facebook.sdk.login错误308?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆