Detect How User Logs in on PFLoginViewController

94 Views Asked by At

I am trying to determine how a user logs in using Parse, either signing in with username and password, logging in with Facebook, or login in with Twitter. I have in my delegate method

- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user {
    BOOL isLinkedToTwitter = [PFTwitterUtils isLinkedWithUser:[PFUser currentUser]];
    BOOL isLinkedToFacebook = [PFFacebookUtils isLinkedWithUser:[PFUser currentUser]];
    if (isLinkedToFacebook) {
//Facebook
NSLog(@"Facebook");
}
if (isLinkedToTwitter) {
//Twitter
NSLog(@"Twitter");
}
else {
//Normal
NSLog(@"Regular Login");
}

The issue is that the else tag is being fired every time. If I login with Facebook, I get the Facebook NSLog and the Regular one. If I login with Twitter I get the Twitter NSLog and the regular one. What am I doing wrong here?

1

There are 1 best solutions below

0
Ero On BEST ANSWER

Change your second if to else if so that it only triggers one of the options

    if (isLinkedToFacebook) {
        //Facebook
        NSLog(@"Facebook");
    } else if (isLinkedToTwitter) {
       //Twitter
       NSLog(@"Twitter");
    } else {
      //Normal
      NSLog(@"Regular Login");
    }