質問

- (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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top