Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I am working on implementing simple Twitter integration. In my appdelegate didFinishLaunchingWithOptions I have:
Code:
 ACAccountStore *store = [[ACAccountStore alloc] init];
    ACAccountType *twitterType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    [store requestAccessToAccountsWithType:twitterType withCompletionHandler:^(BOOL granted, NSError *error) {
        
        if (granted) {
            //access granted;
            
        }
    }];
    [store release];
This will ask for access to twitter accounts, and it works well, but after watching the WWDC video, I am not certain how to add the option to go to Settings and add a Twitter account if none exists already. After I do all this, can I simply use the pain-free Twitter integration and it can easily Tweet?
 
If all you need is basic/simple this should work for you. No need to access the accounts.

Code:
    //create a new instance of tweetComposeViewController
    TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
    
    //set the initial Text
    [tweetSheet setInitialText:[NSString stringWithString:@"Whatever you want"];

     //then present it modal
    [self presentModalViewController:tweetSheet animated:YES];

If you want to make sure they have an account associated with twitter under "Settings" you can check with the following.

Code:
     if ([TWTweetComposeViewController canSendTweet]) {

     }

Take a look at the TWTweetComposeViewController documentation, it's extremely straight forward, it doesn't require api keys or app setup. They will however need to setup an account, I do not know of a way of programmatically sending them to settings.
 
Last edited:
If all you need is basic/simple this should work for you. No need to access the accounts.

Code:
    //create a new instance of tweetComposeViewController
    TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
    
    //set the initial Text
    [tweetSheet setInitialText:[NSString stringWithString:@"Whatever you want"];

     //then present it modal
    [self presentModalViewController:tweetSheet animated:YES];

If you want to make sure they have an account associated with twitter under "Settings" you can check with the following.

Code:
     if ([TWTweetComposeViewController canSendTweet]) {

     }

Take a look at the TWTweetComposeViewController documentation, it's extremely straight forward, it doesn't require api keys or app setup. They will however need to setup an account, I do not know of a way of programmatically sending them to settings.
Thanks. Only reason I wanted to do account lookup was for ease of use so they could either connect it to their twitter account or make one at first launch of app. If anyone else knows programmatically how to detect they don't have account and send them back to settings as option, I'd appreciate it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.