Get some troubles with Parse and Swift. I'm trying to use Facebook Login with Parse class PFFacebookUtils. That's the code:
// LOG IN or SIGN UP with FACEBOOK
@IBAction func FacebookLogin() {
PFFacebookUtils.logInWithPermissions(permissions, {(user: PFUser!, error: NSError!) -> Void in
if error == nil {
if user == nil {
NSLog("Uh oh. The user cancelled the Facebook login.")
let userCancelledAlert = UIAlertController(title: "Error", message: "You cancelled the Facebook Login", preferredStyle: .Alert)
let okButton = UIAlertAction(title: "OK", style: .Default, handler: nil)
userCancelledAlert.addAction(okButton)
let cancelButton = UIAlertAction(title: "Cancel", style: .Default, handler: nil)
userCancelledAlert.addAction(cancelButton)
self.presentViewController(userCancelledAlert, animated: true, completion: nil)
} else if user.isNew {
NSLog("User signed up and logged in through Facebook!")
FBRequestConnection.startWithGraphPath("me?fields=email", completionHandler: { (connection, result, error) -> Void in
if error == nil {
let fbGraphicObject = result as FBGraphObject
println(fbGraphicObject)
}
})
} else {
NSLog("User logged in through Facebook!")
dispatch_async(dispatch_get_main_queue(), { () -> Void in
var homeViewController = self.storyboard?.instantiateViewControllerWithIdentifier("homePage") as HomeViewController
self.presentViewController(homeViewController, animated: true, completion: nil)
})
// end login (success)
}
} else { // if login doesnt work
println(error!)
/*
let facebookError = UIAlertController(title: "Error", message: "Cant connect to Facebook, check your connectivity", preferredStyle: .Alert)
let okButton = UIAlertAction(title: "OK", style: .Default, handler: nil)
facebookError.addAction(okButton)
let cancelButton = UIAlertAction(title: "Cancel", style: .Default, handler: nil)
facebookError.addAction(cancelButton)
self.presentViewController(facebookError, animated: true, completion: nil)
*/
}
})
}
So now my question is: why can't i see what are the permissions when i sign up? I mean, permissions is an array.
let permissions = ["email","user_birthday"]
But when i sign up the message is something like "[APP-NAME] wants to access to your basic info and list of friend. Why not the email or the user_birthday. Then, how can i store those infos in my Parse database? I mean, I see id, username, password (obviously, i have not), authData etc. I have the email field, but it's empty. I guess there's something wrong in the code. Anyone can find? Finally, don't know why, but xCode autocompletion for Parse class (I'm using Swift) doesn't work. I imported the framework (i added the bridging header), and it worked some days ago.