Skip to content

Instantly share code, notes, and snippets.

@vhbit
Created May 6, 2011 10:34
Show Gist options
  • Save vhbit/958738 to your computer and use it in GitHub Desktop.
Save vhbit/958738 to your computer and use it in GitHub Desktop.
Follow us on Twitter button for iOS
- (BOOL)openTwitterClientForUserName:(NSString*)userName {
NSArray *urls = [NSArray arrayWithObjects:
@"twitter:@{username}", // Twitter
@"tweetbot:///user_profile/{username}", // TweetBot
@"echofon:///user_timeline?{username}", // Echofon
@"twit:///user?screen_name={username}", // Twittelator Pro
@"x-seesmic://twitter_profile?twitter_screen_name={username}", // Seesmic
@"x-birdfeed://user?screen_name={username}", // Birdfeed
@"tweetings:///user?screen_name={username}", // Tweetings
@"simplytweet:?link=http://twitter.com/{username}", // SimplyTweet
@"icebird://user?screen_name={username}", // IceBird
@"fluttr://user/{username}", // Fluttr
/** uncomment if you don't have a special handling for no registered twitter clients */
//@"http://twitter.com/{username}", // Web fallback,
nil];
UIApplication *application = [UIApplication sharedApplication];
for (NSString *candidate in urls) {
candidate = [candidate stringByReplacingOccurrencesOfString:@"{username}" withString:userName];
NSURL *url = [NSURL URLWithString:candidate];
if ([application canOpenURL:url]) {
[application openURL:url];
return YES;
}
}
return NO;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment