简体   繁体   English

如何使用Objective-C从设备上安装的本机Twitter应用程序获取用户详细信息

[英]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.

相关问题 从Objective-C iOS 9启动设备Twitter设置 - Launch device twitter settings from objective-c iOS 9 如何从UIWebView传递数据到Objective-C IOS中的本机应用程序 - How to get data from UIWebView pass to Native app in Objective-c IOS 如何使用Objective-C中的Twitter工具包的Digits用户登录 - How to login with Digits User of Twitter kit in Objective-C 如何正确检测设备objective-c的语言用户? - How to detect correctly language user of device objective-c? 通过本机iOS Objective-C应用程序与Python或Java通信吗? - Communicate with Python or Java from native iOS Objective-C app? 在Objective-C中,如何以编程方式获取设备的BuildID - In Objective-C how do you get the BuildID of device programmatically 如何在Objective-C的Twitter中共享文本? - How to share Text in Twitter in Objective-C? 你如何将推送对象从 Urban Airship (Objective-c) 发送到 iOS 设备? - How do you get the push object sent to iOS device from Urban Airship (Objective-c)? 如何使用Objective-C从IOS Cordova中的设备(本地DB)删除图像 - How to delete a image from Device (Local DB) in IOS Cordova using Objective-C 如何使用Objective-C使功能等待通过BLE接收到来自设备的ACK? - How to make a function wait until an ACK from a device is received via BLE using Objective-C?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM