gpt4 book ai didi

ios - ACAccountStore 在设备上返回空数组但在模拟器上工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:10:29 24 4
gpt4 key购买 nike

我正在开发一个应用程序,我想在其中使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com