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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With