PFTwitterUtils logInWithBlock 总是为 userId 返回 nil

编程入门 行业动态 更新时间:2024-10-26 05:18:14
本文介绍了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

本文发布于:2023-10-19 19:17:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1508506.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:logInWithBlock   PFTwitterUtils   nil   userId

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!