[英]How to get user details from native twitter app installed on device using Objective-C
I have implemented twitter login in my iOS app using FSHTwitterEngine. 我已经使用FSHTwitterEngine在我的iOS应用中实现了Twitter登录。 I have also implemented functionality to check for system account using ACAccountStore.
我还实现了使用ACAccountStore检查系统帐户的功能。
Before user log in through both, on button press, How can I check if user has already logged in to twitter native app, and if so get the user data from over there, then come back to my app. 在用户通过两者登录之前,请先按一下按钮,如何检查用户是否已经登录到Twitter本机应用程序,如果是,则从那里获取用户数据,然后返回我的应用程序。 (Same as FBSDKLoginBehaviorNative for facebook.)
(与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];
From above code you can check if user have twitter accounts in his phone using ACAccountStore. 通过上面的代码,您可以使用ACAccountStore检查用户手机中是否有Twitter帐户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.