Parse + Facebook

Parse + Facebook

:

  • Facebook
  • , Facebook (, , ..)

, Facebook, PFFacebookUtils

. , , Facebook, .

, , .. Facebook.

?

    var permissionArray = ["public_profile","user_friends","email","user_birthday", "user_work_history", "user_education_history", "user_hometown", "user_location", "user_likes"]; on Facebook

        PFFacebookUtils.logInInBackgroundWithReadPermissions(permissionArray) { (user: PFUser?, error: NSError?) -> Void in
            if user != nil {
                if user!.isNew {
                    println("New User");
                }
                else {
                    println("Old  User");
                }
                println(user?.username);
            }
            else {
                println("Login Cancel")
            }
        }

      

+3




1


You need to request the data of the user "me" and then you can use that to populate your custom object. So in yours if user!.isNew {

you need to do something line by line ...

let fbDetailsRequest = FBRequest.requestForMe()
fbDetailsRequest.startWithCompletionHandler { connection, result, error in
  if error != nil {
    // Handle the error
  }

  if let graph = result as? FBGraphObject {
    // Now you can fill out the data on your user object
    user!.setObject(graph.objectForKey("email")!, forKey: "email")
    user!.setObject(graph.objectForKey("gender")!, forKey: "gender")
    // Don't forget to save afterwards...
    user!.saveInBackgroundWithBlock(nil)
  }
}

      



To see the fields you can capture, see https://developers.facebook.com/docs/graph-api/reference/user If you need anything other than the "core" elements, you may need to have additional permissions.

0


source







All Articles