When users upgraded to iOS 7, they had to re-authorize their Twitter accounts. Currently, I have a problem which seems to arise from when a user has multiple accounts, one or more of which is not verified.
When a user has multiple accounts, and one requires authorization, running this method will give a completion handler with YES, and a nil error:
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
}];
Continuing onwards, the app will fail to access Twitter from that account, and cause a crash.
Reading the documentation shows that ACAccount has a credential
property, but that this property is inaccessible after the account is saved
, so that can't be used as an indicator.
ACAccountStore does have another method:
- (void)renewCredentialsForAccount:(ACAccount *)account completion:(ACAccountStoreCredentialRenewalHandler)completionHandler
But this forces the user to renew their credentials when it's called, not ideal if they already have.
How can I actually find out if an account requires it's credentials be renewed, or if it's accessible?