Skip to content

Instantly share code, notes, and snippets.

@tillawy
Last active February 12, 2016 08:44
Show Gist options
  • Save tillawy/606f0d1e463f7aa901f2 to your computer and use it in GitHub Desktop.
Save tillawy/606f0d1e463f7aa901f2 to your computer and use it in GitHub Desktop.
use fbsdk swift to get fb user email
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