ios - 如何使用 Objective-C 从安装在设备上的 native twitter 应用程序获取用户详细信息

标签 ios objective-c twitter

我已经使用 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/

相关文章:

ios - 如何枚举 CFProperyList/CFDictionary 键

javascript - React Native 中显示 Activity 指示器时如何锁定所有屏幕的触摸?

ios - IBOutlet 表示已在 StoryBoard 中连接,但未在代码中表示连接

ios - UIPageViewController 在访问 UITableView 内容后不加载页面内容

ios - 如何点击 UITableViewCell 中的 UIButton 并转换到新的 View Controller ,并向其传递信息?

python - 在 Twitter OAuth POST 请求上获取 401

UILabel 上的 iOS 渐变效果

ios - 如果用户在其他地方单击然后 UIPickerView,如何使 UIPickerView resignFirstResponder

android - 使用 Fabric SDK 获取 Twitter 用户电子邮件

java - Vaadin 中的嵌入推文