【发布时间】:2017-01-19 07:05:31
【问题描述】:
我正在使用 FBSDK4.18.0 在 iOS 中以 Swift3 语言集成 Facebook 登录。下面是以下代码:但确实如此 不打印结果,包括
func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
print("User Logged In")
if ((error) != nil)
{
// Process error
}
else if result.isCancelled {
// Handle cancellations
}
else {
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if result.grantedPermissions.contains("public_profile")
{
// Do work
// let strFirstName: [String: Any]? = (result.objectForKey("first_name") as? String)!
// let strLastName: String = (result.objectForKey("last_name") as? String)!
// let strPictureURL: String = (result.objectForKey("picture")?.objectForKey("data")?.objectForKey("url") as? String)!
if let dic = result as? [String: Any]
{ if let strFirstName = dic["first_name"] as? String, let strLastName = dic["last_name"] as? String
{
print("\(strFirstName) \(strLastName)")
}
}
}
}
}
它还显示了“来自 'FBSDKLoginManagerLoginResult!' 的演员表!”到不相关的类型 '[String : Any]' 总是失败”警告在“if let dic = result as?[String: Any]”
【问题讨论】:
标签: ios swift3 facebook-sdk-4.0