I wanted to known how to pass the values in result to another view controller.
func showEmailAddress() -> Void{
//Adding user to firebase
let accessToken = FBSDKAccessToken.current()
guard let accessTokenString = accessToken?.tokenString else //This makes things a littie safer
{return}
let credentials = FacebookAuthProvider.credential(withAccessToken: accessTokenString)
Auth.auth().signIn(with: credentials) { (user, error) in
if error != nil {
print("something went wrong with out FB user: ", error ?? "")
return
}
print("Successfully logged in with our user: ", user ?? "")
UserDefaults.standard.set(user!.email!, forKey: "usersigned")
UserDefaults.standard.synchronize()
let delegate : AppDelegate = UIApplication.shared.delegate as! AppDelegate
delegate.rememberLogin()
}
//print("Succesfully loged in with facebook...")
FBSDKGraphRequest(graphPath: "/me", parameters: ["fields": "id, name, email"]).start { (connection, result, err) in
//print(123)
if err != nil{
print("Failed to start graph request:",err ?? "")
return
}
print("This is the results")
print(result ?? "")
let data:[String:AnyObject] = result as! [String : AnyObject]; print(data["name"]!); print(data["id"]!)
var username = data["name"]!
var userID = data["id"]!
//let number = "1234566"
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let DestViewController : menuViewController = segue.destination as! menuViewController
DestViewController.id = username
}
The values are only existing inside the showEmailAddress(). Is there a way extract them from the function to send username and userID to a another VC?