1

I followed a tutorial in creating a welcome screen with ParseUI and included its provided Facebook button. The simulator now logs into Facebook, but does not create a PFUser in my Parse App Database. There is an extra code for this that I know I need to add (pasted below), but I don't know where, since I don't have an Outlet for the ParseUI Facebook button, or any function that i know is called when this button is clicked.

PFFacebookUtils.logInInBackgroundWithReadPermissions("public_profile") {
(user: PFUser?, error: NSError?) -> Void in
if let user = user {
if user.isNew {
print("User signed up and logged in through Facebook!")
} else {
print("User logged in through Facebook!")
}
} else {
print("Uh oh. The user cancelled the Facebook login.")
}
}
rici
  • 234,347
  • 28
  • 237
  • 341
Jacobo Koenig
  • 11,728
  • 9
  • 40
  • 75

1 Answers1

0

I recently wrote a sort of how-to on using the Facebook login button with Parse. The link to the full thing is here. However, I'll outline the 3 basic steps for you to understand it a bit better. If you don't understand anything, check out that answer I linked to (or just let me know).

1: You set up a FaceBook Btn, and set it's delegate to your VC, and set your VC to inherit from the FBSDKLoginButtonDelegate.

2: Set up what data to use from their FBProfile in a returnUserData() method, and trigger this in the FBButton delegate.

3: This part is not in my walkthrough I linked to, put the PFFacebookUtils.logInInBackgroundWithAccessToken(FBSDKAccessToken.currentAccessToken(), block: { (user: PFUser?, error: NSError?) -> Void in //do your cool stuff here, like adding FBData to your user and saving... } method within the success part of the graphRequest (so the else after error != nil)

That's about it. Easy if you know what to do. A nightmare if you don't.

Community
  • 1
  • 1
MQLN
  • 2,292
  • 2
  • 18
  • 33
  • Thank you for your answer! It seems that you are referring to creating Facebook SDK's Login Button in your tutorial, and not using ParseUI's Facebook Button which is included in its PFLogInViewController. My question is how I would use this button to get Facebook's information and upload it to my database. In any case, I tried setting that class to delegate FBSDKLoginButtonDelegate like this: >> class LoginViewController : PFLogInViewController, FBSDKLoginButtonDelegate { but it says it does not conform to my class Again, thanks for helping! – Jacobo Koenig Nov 20 '15 at 03:22