11

I am using TWTweetComposeViewController to access a user's twitter account(s), which he/she has added in Settings -> Twitter. When the app attempts to access a twitter account, it should presente an alert with a message similar to this:

"[AppName] Would Like Access to Twitter Accounts"

To which you can tap either "Don't allow" or "OK". I suppose this is an alert displayed by the OS itself, since tapping "OK" actually enables access to twitter.

The above alert is displayed when I test it on an iOS 5.x device, but that is not the case when I test it on an iOS 6 device. I expect the alert to be presented when I send the following message, and I have not yet gained my app access to Twitter in settings:

[TWTweetComposeViewController canSendTweet]

As described, it does not happen. Does anyone know if this is a known bug in iOS 6? I have been unable to find any posts on SO and since I can find no other reason to the different behavior I believe it's a bug.

FYI, I am testing this on the following two devices:

  • iPhone 4 with iOS 5.1
  • iPhone 4 with iOS 6.0

Update

I use DETweetComposeViewController, which checks for iOS 5 in the following way:

+ (BOOL)de_isIOS5
{
    return (NSClassFromString(@"NSJSONSerialization") != nil);
}

But since the NSJSONSerialization class is represented in iOS 6 as well, this shouldn't be the reason.

allprog
  • 16,540
  • 9
  • 56
  • 97
Kasper Munck
  • 4,173
  • 2
  • 27
  • 50

1 Answers1

30

I have been sorting this same thing out on iOS 5.1 vs iOS 6.0 all day.

As long as there is a Twitter account configured in Settings, my app no longer asks for Twitter access permission in iOS 6.0 just to display a TWTweetComposeViewController. I have verified this by manually turning off Twitter access for my app in Settings > Privacy > Twitter. With access off, I am properly denied the ability to create a friendship using TWRequest, but can still pop up the TWTweetComposeViewController. I get a prompt in iOS 5.1 every time until I grant it access.

This makes sense to me. All TWTweetComposeViewController does is initiate the tweet, so if the user already has a device-wide Twitter account configured, that should be permission enough to send tweets from anywhere. It really is an unnecessary extra step to have to grant access on a per-app basis.

If no Twitter accounts are configured yet, TWTweetComposeViewController will prompt with this message tho:

No Twitter Accounts
There are no Twitter accounts
configured. You can add or create
a Twitter account in Settings.

with handy buttons "Settings" and "Cancel".

A sidenote to this: iOS 6 also only prompts with the "[AppName] Would Like Access to Twitter Accounts" message the first time an app requests access.

After that you must reset Settings > General > Reset > Reset Location & Privacy to get the ask prompt back. Even if you delete and reinstall/rebuild an app, the "already asked once" setting persists. You can manually enable access in Settings > Privacy, but that reset is the only way to get the prompt to redisplay (if that is important to your testing).

Two extra things I found out. In the completion block of [ACAccountStore requestAccessToAccountsWithType:options:completion:], if granted == NO:

  1. If [error code] == 6, your user has no accounts defined.
  2. If error == nil, your user denied access for your app, either just now or previously. If it happened previously, the request is silently ignored with no alert displayed on the screen, no "Don't Allow" button to tap.
balord
  • 316
  • 3
  • 2
  • Thank you very much for the answer. I recently discovered that TWTweetComposeViewController is deprecated as of iOS 6 and instead Apple wants us to use SLComposeViewController. I will test if it's the same case with SLComposeVC and post the results. – Kasper Munck Oct 03 '12 at 18:43
  • I've been testing with iOS6 in the simulator and have never seen the "[AppName] Would Like Access to Twitter Accounts" message - it just sends without prompting for permission. Very odd. Haven't tried on a device yet. – Andy Waite Jan 06 '13 at 18:58
  • I recommend that you try it on a device ! – Ahsan Feb 16 '13 at 02:06
  • Very helpful answer. I just wonder is there some SDK identifier instead of using '[error code] == 6' since I prefer identifiers compared to hard coded values because of future compiles. – vedrano Mar 21 '13 at 19:25
  • The enum is found in , but they won't change any values for code-compatibility reasons. – Justin Johns May 07 '14 at 22:10
  • is there a way to prevent this prompt from ever coming up with programmatically making it chose disallow? – Will Von Ullrich Aug 10 '15 at 18:39