[英]Facebook SDK Login doesn't work on simulator on iOS 10, Xcode 8
I try to login via the Facebook SDK login system in viewWillAppear
like so: 我尝试通过viewWillAppear
的Facebook SDK登录系统登录,如下所示:
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. 这并不正确真实设备在iOS模拟器10的工作,但最近,使用Xcode中8和斯威夫特3似乎失败。 The login button works normally and prompts to login and authorization page, but after authorizing/logging in, the token ( FBSDKAccessToken.current()
) remains nil
. 登录按钮正常工作并提示登录和授权页面,但在授权/登录后,令牌( FBSDKAccessToken.current()
)仍nil
。
Again, the problem only applies on the simulator, using iOS 10, Xcode 8 and Swift 3. 同样,该问题仅适用于模拟器,使用iOS 10,Xcode 8和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 . 如果它在真实设备上正常工作,这意味着您已成功集成了Facebook SDK 。 In order to make things working on iOS 10 simulator : 为了使东西在iOS 10模拟器上工作:
Go to the Project Target
and then Capabilities
and switch Keychain Sharing ON . 转至Project Target
,然后Capabilities
和开关钥匙链 上 分享 。
It will ask for a Team for the first time. 它将首次要求团队。 Select a team and it will add a Keychain Group for you. 选择一个团队,它将为您添加一个Keychain Group。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.