【问题标题】:ACAccountStore return empty array on device but works on SimulatorACAccountStore 在设备上返回空数组,但在模拟器上工作
【发布时间】:2013-04-14 01:03:23
【问题描述】:

我正在开发一个应用程序,我想使用 SLRequest 在 Twitter 上发帖。我已经让它在模拟器上工作,但它不能在我的设备上工作。

 [self.accountStor accountsWithAccountType:accountTypeTwitter];

在我的设备上返回一个空数组,但它会在模拟器上显示正确的帐户。我不知道为什么会这样。

我有一个获取用户 Twitter 帐户的方法。它看起来像这样:

- (void)fetchTwitterAccounts
{
    if (self.accountStore == nil) {
        self.accountStore = [[ACAccountStore alloc] init];
    }

    ACAccountType *accountTypeTwitter = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    self.twitterAccounts = [self.accountStore accountsWithAccountType:accountTypeTwitter];
    [self.tableView reloadData];
}

关于为什么我的设备上没有任何帐户的任何想法?

【问题讨论】:

    标签: ios cocoa-touch twitter slrequest


    【解决方案1】:

    您有 Twitter 帐户,并且该应用有权在您的设备上使用它们?在尝试获取帐户列表之前,您是否调用了requestAccessToAccountsWithType

    查看下面的示例,如何通过首先请求访问以及仅在检索帐户列表的用户授予权限时检索帐户列表

    https://dev.twitter.com/docs/ios/making-api-requests-slrequest(特别是第 32-42 行)。

    【讨论】:

      猜你喜欢
      • 2015-11-10
      • 2018-02-06
      • 2012-08-19
      • 2023-03-23
      • 2012-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多