0

After logging in with Facebook SDK. I am able to create a new PFUser but the e-mail address of this user does not save in my Databrowser. How can I get this done?

Action for the button:

- (IBAction)didTapFb:(id)sender {

[activityIndicator startAnimating];

PFUser *user = [PFUser currentUser];
if (![PFFacebookUtils isLinkedWithUser:user]) {
        [PFFacebookUtils linkUser:user permissions:nil block:^(BOOL succeeded, NSError *error) {
            if (succeeded) {
                NSLog(@"Woohoo, user logged in with Facebook!");
            }
        }];

NSArray *permissionsArray = @[ @"user_about_me", @"user_relationships", @"user_birthday", @"user_location", @"email"];

[PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
    if (!user) {
        if (!error) {
            NSLog(@"Uh oh. The user cancelled the Facebook login.");
        } else {
            NSLog(@"Uh oh. An error occurred: %@", error);
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Error en conexión." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        }
    } else if (user.isNew) {
        NSLog(@"User with facebook signed up and logged in!");
        [self performSegueWithIdentifier:@"MaintoLook" sender:self];
    } else {
        NSLog(@"User with facebook logged in!");
        [self performSegueWithIdentifier:@"MaintoLook" sender:self];

        [activityIndicator stopAnimating];
    }
}];
}
}

enter image description here

adriennemhenry
  • 133
  • 1
  • 3
  • 17
  • Save it as you would any PFObject... – Lyndsey Scott May 15 '14 at 02:53
  • @LyndseyScott could you help with some code? I don't know how to get the email first. – adriennemhenry May 15 '14 at 03:02
  • 2
    Here's how you access the email: http://stackoverflow.com/a/11844297/2274694 . Here's how you save the PFObject: https://parse.com/docs/ios_guide#objects-saving/iOS . – Lyndsey Scott May 15 '14 at 03:05
  • @LyndseyScott it works but not as I intended. What I actually want is for the email to be saved in the User Class of my Data Browser but it is actually creating a new class. I am adding an image to the question. Please View. – adriennemhenry May 15 '14 at 03:28
  • 3
    You have to save the object to the user, not to a brand new class. So when saving "currentUser" should be your class, ex: [[PFUser currentUser] setObject:email forKey:@"email"]; [[PFUser currentUser] saveInBackground]; – Lyndsey Scott May 15 '14 at 03:34
  • @LyndseyScott Does it still working? It`s returning me nothing, wrong method. – Milan1111 Jun 22 '14 at 22:47
  • @Milan1111 I don't know what you mean by "it." You should probably just post your own question to find out what's going wrong with your particular code... – Lyndsey Scott Jun 23 '14 at 00:50
  • @LyndseyScott I already posted the question. Can you check it, please? http://stackoverflow.com/questions/24350412/parse-recieve-e-mail-fb-sdk – Milan1111 Jun 23 '14 at 10:08

0 Answers0