Oli Black
Oli Black

Reputation: 441

Check is Parse user is already linked to facebook or twitter

I have set up a few Parse users, I have a button that they can click to link to fb or twitter. I want to check if they are already linked so I can have an alertview which tells the user they are already linked.

Any thoughts?

Upvotes: 0

Views: 687

Answers (2)

Nico
Nico

Reputation: 1326

You can use PFQuery for this:

id loggedUser = ...; // Get your facebook/twitter user info after clicking login
PFQuery *query = [PFUser query];
[query whereKey:@"email" equalTo:loggedUser[@"email"]];
[query countObjectsInBackgroundWithBlock:^(int number, NSError *error) {
    if(number > 0) {
        // The user already exists
    } else {
        // No user exists with the email
    }
}];

Source: Parse.com

Upvotes: 1

Wain
Wain

Reputation: 119031

Parse provides a set of utils for this kind of thing, one part of which is:

+ (BOOL)isLinkedWithUser:(PFUser *)user

Upvotes: 1

Related Questions