Facebook SDK Login doesn't work on simulator on iOS 10, Xcode 8

Deadly 提交于 2019-12-10 15:48:13

问题


I try to login via the Facebook SDK login system in viewWillAppear like so:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    if !loggedIn {
        if let token = FBSDKAccessToken.current() {
            loggedIn = true
            self.accessToken = token
        } else {
            let login = FBSDKLoginButton()
            login.center = view.center
            view.addSubview(login)
        }
    }
}

This does work properly on a real device, but lately on the iOS 10 simulator, using Xcode 8 and Swift 3 it seems to fail. The login button works normally and prompts to login and authorization page, but after authorizing/logging in, the token (FBSDKAccessToken.current()) remains nil.
Again, the problem only applies on the simulator, using iOS 10, Xcode 8 and Swift 3.

What could be the problem and how can I get this to work on the simulator? Thanks in advance.


回答1:


If its working fine on a real device, this means that you have successfully integrated the Facebook SDK. In order to make things working on iOS 10 simulator :
Go to the Project Target and then Capabilities and switch Keychain Sharing ON.
It will ask for a Team for the first time. Select a team and it will add a Keychain Group for you.



来源:https://stackoverflow.com/questions/39786577/facebook-sdk-login-doesnt-work-on-simulator-on-ios-10-xcode-8

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