Search code examples
iosfacebookemailparse-platformparseui

Missing e-mail when using ParseUI with Facebook login/signup


I'm using the the PFLogInViewController of the ParseUI framework. I have two questions related to emails with regards to Facebook Login within the framework:

1) When signing up via Facebook, I see that the email field of my new user is 'undefined.' How can I obtain the user's email address?

2) If I am able to obtain the email address, does parse's application setting of 'emailVerified' still send a verification email to the user upon Facebook signup? If not, how can this be done?

Thanks.


Solution

  • In order to read the user's email address you'll need to add email to your array of Facebook permissions you're requesting. Look at the Parse tutorial on this https://www.parse.com/tutorials/login-and-signup-views#properties

    In your case, you'll want to add @"email" like this:

    [logInViewController setFacebookPermissions:[NSArray arrayWithObjects:@"friends_about_me", @"email", nil]];
    

    Then when you are requesting the user information from Facebook, you will be able to access the user's email address:

    FBRequest *request = [FBRequest requestForMe];
            [request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    
                if (!error) {
                    // Now you can access user's email
                    NSString *email = result[@"email"];
                    if (email) {
                        // Save it to your email field in Parse
                    }
                }
            }];
    

    Regarding part 2 of your question, I'm not as familiar with the email validation functionality that Parse supports, but looking at this (admittedly old) response https://www.parse.com/questions/email-verification-emails-going-out-to-facebook-users it appears that Parse will validate email addresses even when the user logs in with Facebook.