I was integrating Facebook Login SDK, in my app and I am new to this. I implemented it, but now I want to get the email. So, following the tutorial I created the same function as the tutorial showcased.
Here is the function:
func fetchProfile()
{
print("Fetch Profile")
let parameters: [String : Any] = ["fields" : "email, first_name, last_name, picture.type(large)"]
FBSDKGraphRequest(graphPath: "me", parameters: parameters).start(completionHandler: {
(connection, result, error) -> Void in
if error != nil {
print(error!)
return
}
if let email = result["email"] as? String {
print(email)
}
}
}
So, the programmer was using Swift 3 there and I am using Swift 4 here, so is it creating any issue? And, it says Type "Any" has no subscript members
where if let email =
is written. How to solve this?
cast result to [String:Any]
if let resultDict = result as? [String:Any]{
if let email = resultDict["email"] as? String {
print(email)
}
}