2015-05-23 38 views
0

PFTwitterUtils的logInWithBlock方法總是返回userId爲nil。 任何想法,爲什麼這可能會發生?PFTwitterUtils logInWithBlock對於userId總是返回nil

我使用parse.com版本:1.7.2

[PFTwitterUtils logInWithBlock:^(PFUser *user, NSError *error) { 
     if (!user) { 
      NSLog(@"Uh oh. The user cancelled the Twitter login."); 
      return; 
     } else if (user.isNew) { 
      NSLog(@"User signed up and logged in with Twitter!"); 

      if([PFTwitterUtils isLinkedWithUser:user]){ 
       NSLog(@"userID %@", [PFTwitterUtils twitter].userId); 
      } 

     //... 

     } else { 
      NSLog(@"User logged in with Twitter!"); 
     } 
    }]; 

回答

0

的用戶ID的原因是零,因爲該用戶已經被記錄在設備上。 如果您在設備上進行了大量測試並忘記進行註銷,則可能會發生這種情況。

如果您在嘗試重新登錄之前註銷,則無損。

所以這裏是一個測試的例子:

[PFUser logOut]; 

[PFTwitterUtils logInWithBlock:^(PFUser *user, NSError *error) { 
     if (!user) { 
      NSLog(@"Uh oh. The user cancelled the Twitter login."); 
      return; 
     } else if (user.isNew) { 
      NSLog(@"User signed up and logged in with Twitter!"); 

      if([PFTwitterUtils isLinkedWithUser:user]){ 
       NSLog(@"userID %@", [PFTwitterUtils twitter].userId); 
      } 

     //... 

     } else { 
      NSLog(@"User logged in with Twitter!"); 
     } 
    }];