本文介绍了PFTwitterUtils logInWithBlock 总是为 userId 返回 nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PFTwitterUtils 的 logInWithBlock 方法总是返回 userId 为 nil.知道为什么会发生这种情况吗?
The logInWithBlock method of PFTwitterUtils always returns userId as nil. Any idea why this might be happening?
我使用的是 parse 版本:1.7.2
I am using parse version: 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!"); } }]; 推荐答案userId 为 nil 的原因是该用户已经在设备上登录.如果您在设备上进行了大量测试而忘记注销,则可能会发生这种情况.
The reason userId is nil is because this user has been already logged in on the device. This might happen if you are testing a lot on your device and forget to do a logout.
如果您在尝试再次登录之前先退出,那就没问题了.
If you logout before you attempt to login again it will be fine.
这里是一个测试示例:
[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!"); } }];更多推荐
PFTwitterUtils logInWithBlock 总是为 userId 返回 nil
发布评论