ACAccountStore requestAccessToAccountsWithType:options:completion:accountStoreHandler returns granted = NO immediately

704 Views Asked by At

I am trying to integrate Twitter into my app using iOS's Accounts framework. I call:

ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *twitter = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:twitter
                                      options:NULL
                                   completion:accountStoreHandler];

where accountStoreHandler is my long C block defined earlier. However, when I run the code, accountStoreHandler is fired immediately with granted = NO and error = nil without even asking me to access my Twitter accounts. When I go to settings and from there Twitter, I see that my app is not given access to Twitter (I can see all other apps are granted there, and yes, I do have a valid/working Twitter account on my device). The problem is that, it didn't even as me. Moreover, I've deleted and rebuilt my app, but it still doesn't ask me to access Twitter. I need to test Twitter login functionality with corner cases, but I can't ensure that everything is working properly if I grant Twitter access manually from settings. What is the correct way to test initial Twitter login functionality?

For clarification: Yes, I can grant access from settings manually and it works, but I'm looking for a way to "simulate" a device that has just installed the app, which I can't replicate on my device (and it's a photo app with ARM libraries so that I can't test it on simulator).

1

There are 1 best solutions below

0
On

Based on my experience, the granted accesses will be stored even after we delete the app.

I suggest you to try the features in simulator instead, if you want to try it again, you can always reset the simulator.

n.b.: I know it is 5 months late to answer this question, but I hope somebody who search for this question will find it useful :)