- (void)authTwitter {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType
options:nil
completion:^(BOOL granted, NSError *error){
if (granted) {
NSArray *accounts = [accountStore accountsWithAccountType:accountType];
// always there, but accounts array is empty
} else {
}
}];
I was expecting to see some prompt from iOS, but granted always YES. I DO NOT have account set-up on my iPhone.
Does it mean that it's too much time I've been programming and should go outside? Or I simply missed something?
iOS 7, both device and simulator have same behaviour.
You're already there. Completion block should be:
{
bool actuallyGranted = granted;
NSArray *accounts = [accountStore accountsWithAccountType:accountType];
if (!accounts || ([accounts count] == 0))
actuallyGranted = false;
if (actuallyGranted)
{
}
else
{
}
}
A similar call for FB does not need this - value for "granted" will be correct. I'm assuming the special case needed for twitter is an iOS bug.