Вопрос

I'm working on an app where I want to post to Twitter using SLRequest. I have got it to work on the simulator, but it dosn't work on my device.

 [self.accountStor accountsWithAccountType:accountTypeTwitter];

Returns an empty array on my device, but it show the correct accounts on the simulator. I have no idea why this is happening.

I have a method in which I fetch the users Twitter account(s). It looks like this:

- (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];
}

Any ideas on why I don't get any accounts on my device?

Это было полезно?

Решение

You have Twitter accounts and the app is authorised to use them on your device? Do you invoke requestAccessToAccountsWithType before you try to get the list of accounts?

Check the example below how the list of accounts is retrieved by first requesting access and only if granted by the user retrieving the list of accounts

https://dev.twitter.com/docs/ios/making-api-requests-slrequest (in particular lines 32-42).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top