How can I tell the difference between an app not having Twitter access and Twitter having no accounts Setup?

StackOverflow https://stackoverflow.com/questions/11457818

Вопрос

I understand how to ask for Twitter access using:

requestAccessToAccountsWithType:withCompletionHandler:

But this pops a dialogue if the app isn't authorised. How can I silently check to see if the app is authorised?

I can check the number of accounts using:

 NSArray *twitterAccounts = [store accountsWithAccountType:twitterAccountType];

But I will get an empty array back if I the app is not authorized AND if there are no accounts available. I can't see a way of finding out which of these is the case.

To clarify I need to tell the difference between the following cases:

  1. A user has not granted the application permission to use Twitter.
  2. A user has granted permission but has not set up any Twitter accounts.

There is also TWTweetComposeViewController canSendTweet which will return true if The app is authorised AND there is at least one account setup. However, again this doesn't give me the ability to tell the difference between the two cases if it returns false.

Это было полезно?

Решение

It looks like there's an accessGranted property of each account type you can check to see if you've been authorized to use it: http://developer.apple.com/library/ios/#DOCUMENTATION/Accounts/Reference/ACAccountTypeClassRef/Reference/Reference.html#//apple_ref/doc/uid/TP40011022

So I'd check that to see if you've been authorized first, and if so, then pull the list of twitter accounts and see if there's anything in the array.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top