我已经使用 FSHTwitterEngine 在我的 iOS 应用程序中实现了 Twitter 登录。我还实现了使用 ACAccountStore 检查系统帐户的功能。
在用户通过两者登录之前,按下按钮,我如何检查用户是否已经登录到 Twitter native 应用程序,如果是,则从那里获取用户数据,然后返回到我的应用程序。 (与 facebook 的 FBSDKLoginBehaviorNative 相同。)
BOOL twInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"twitter://"]];
if (twInstalled)
{
// here I want to check for the user if he/she is logged in and get data.
}
else
{
[self twitterLoginWithsystemAccount]
// or
[self twitterLoginWithFHSTwitterEngine];
}
最佳答案
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
NSArray *accounts = [accountStore accountsWithAccountType:accountType];
ACAccount *twitterAccount = [accounts lastObject];
通过上面的代码,您可以使用 ACAccountStore 检查用户的手机中是否有 Twitter 帐户。
关于ios - 如何使用 Objective-C 从安装在设备上的 native twitter 应用程序获取用户详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35911424/