我正在开发一个应用程序,我想使用 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];
}
关于为什么我在我的设备上没有任何帐户有什么想法吗?
最佳答案
您有 Twitter 帐户并且该应用已获授权在您的设备上使用它们?在尝试获取帐户列表之前,您是否调用 requestAccessToAccountsWithType
?
检查下面的示例,如何通过首先请求访问权限并且仅在检索帐户列表的用户授予访问权限的情况下检索帐户列表
https://dev.twitter.com/docs/ios/making-api-requests-slrequest (特别是第 32-42 行)。
关于ios - ACAccountStore 在设备上返回空数组,但在模拟器上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16124901/