accountsWithAccountType returning empty array

1.7k views Asked by At

iOS6. I signed in to Twitter in the Settings app.

I closed my app and the Settings app then re-ran.

ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *accountType = [store  accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[self createAccountPickerForAccountType:accountType withStore:store];

...

- (void)createAccountPickerForAccountType:(ACAccountType *)accountType withStore:
self.accounts = [store accountsWithAccountType:accountType];
[self displayAccountPicker];

the array returned is an empty array.

1

There are 1 answers

1
Seth Spitzer On

I see this too on my phone, but it works in the simulator.

I'm doing:

ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *twitterAccountType =
[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[store requestAccessToAccountsWithType:twitterAccountType options:nil^(BOOL granted, NSError *error) {

    NSArray *twitterAccounts =  [store accountsWithAccountType:twitterAccountType];
    int count = [twitterAccounts count];
}];

From https://dev.twitter.com/docs/ios-frequently-asked-questions

"Why is my application attributed as "from iOS" instead of "from " on twitter.com?

If your application is not yet live in the App Store:

The application making the requests must be launched in Apple's App Store in order for the attribution to display on twitter.com. Note that the iOS5 version of the application must be live, not just a previous version."

I wonder if it could because my app isn't in the app store yet?