Integrate Twitter into iOS 5 but keep backward compatible with older iOS

Following this great tutorial on how to integrate twitter into your application. I know that there are other ways that programmers used to integrate twitter before iOS 5, but my question is this:

My application supports iOS 3.0+, so if I integrate twitter using only the iOS 5 method, how will this affect my users who don’t use iOS 5? Will this work for them?

Thank!

+3
source share
4 answers

The official API structure will not work, unfortunately, since twitter application / integration is only available in iOS 5

ShareKit, API, Twitter, facebook .

+4

, Twitter iOS 5, , Twitter:

// Don't forget to import Twitter!
#import <Twitter/Twitter.h>
....
if([TWTweetComposeViewController class] != nil) {
    // your code here
}

, , Twitter .

+5

You should see the DETweetComposeViewController . We built it for this purpose. This is an iOS4 compatible reimplementation of TWTweetComposeViewController.

+2
source

Use a weak link and some code as shown below:

 - (void)tweet
{
Class tweeterClass = NSClassFromString(@"TWTweetComposeViewController");

if(tweeterClass != nil) {   
    if([TWTweetComposeViewController canSendTweet]) {
        TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
        tweetViewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
            if(result == TWTweetComposeViewControllerResultDone) {

            }
            [self dismissViewControllerAnimated:YES completion:nil];
        };

        [self presentViewController:tweetViewController animated:YES completion:nil];
    } else {
#if !(TARGET_IPHONE_SIMULATOR)
        [self displayAlert:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup."];
#else
        NSString *tweetString = [NSString stringWithFormat:@"http://mobile.twitter.com/home?status=%@%@", [self urlEncode:@"Check out this awesome pic: "] ,[self urlEncode:[_blobTweet.shortUrl absoluteString]]];
        NSURL *tweetURL = [NSURL URLWithString:tweetString];
        if ([[UIApplication sharedApplication] canOpenURL:tweetURL]) { 
            [[UIApplication sharedApplication] openURL:tweetURL]; 
        }
#endif
    }
} else {        
    // no Twitter integration could default to third-party Twitter framework

}
}

@end
0
source

All Articles