我收到错误代码:
The operation couldn’t be completed. (com.facebook.sdk.core error 3.)
在我的应用上登录Facebook并且不确定原因。这是我的viewController代码:
import FBSDKCoreKit
import FBSDKLoginKit
@IBOutlet weak var facebookLoginButton: FBSDKLoginButton!
override func viewDidLoad() {
super.viewDidLoad()
facebookLoginButton.readPermissions = ["public_profile", "email", "user_friends"]
facebookLoginButton.delegate = self
}
//MARK: Facebook Login
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
if error == nil {
print("Login Complete")
performSegueWithIdentifier("facebookSegue", sender: self)
} else {
print(error.localizedDescription)
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
print("User logged out")
}
这是appDelegate:
import FBSDKCoreKit
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//Facebook login
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
//Facebook login
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
我认为代码是正确的,但也许我错过了什么,感谢任何帮助!
答案 0 :(得分:3)
如果将Facebook iOS SDK升级到版本4.39.0,则存在一个导致此错误的错误。降级到4.38.1将帮助您解决此问题。确保同时降级FBSDKCoreKit和FBSDKLoginKit。
pod 'FBSDKCoreKit', '~> 4.38.0'
pod 'FBSDKLoginKit', '~> 4.38.0'
请确保清理构建文件夹并重新构建SDK。
答案 1 :(得分:0)
能够弄清楚。 plist文件必须修改如下:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fb</string>
<string>fbapi</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fb-messenger-api</string>
</array>
添加后它起作用了!