質問

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