Last active
February 12, 2016 08:44
-
-
Save tillawy/606f0d1e463f7aa901f2 to your computer and use it in GitHub Desktop.
use fbsdk swift to get fb user email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let login = FBSDKLoginManager() | |
login.logInWithReadPermissions([ "email" ], fromViewController: self) { (result: FBSDKLoginManagerLoginResult!,error: NSError!) -> Void in | |
if (error != nil){ | |
SVProgressHUD.showErrorWithStatus(error.localizedDescription) | |
} else if (result.isCancelled) { | |
SVProgressHUD.showWithStatus("Canceled") | |
} else { | |
self.logger.info("fb token: \(result.token.tokenString)") | |
let params = ["fields" : "email,name"] | |
FBSDKGraphRequest(graphPath: "me", parameters: params).startWithCompletionHandler({ (connection: FBSDKGraphRequestConnection!, result: AnyObject!, error: NSError!) -> Void in | |
if error != nil { | |
self.logger.error("error: \(error)") | |
} else { | |
self.logger.info("fb email: \(result)") | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment