1

Is there anyway to open the twitter app from an html link on an iPhone? Kind of how when you click a youtube link it goes to the youtube app.

thanks

evenodd
  • 2,026
  • 4
  • 26
  • 38
  • 1
    Possible duplicate. [See this post](http://stackoverflow.com/questions/2095638/iphone-apps-can-i-open-an-app-from-a-link-in-a-website). – sczizzo Jun 13 '12 at 15:39

3 Answers3

2

You'd use twitter:// as the URL and put it in an action for a button or something like so:

-(IBAction)openTwitter{
   NSURL* url = [NSURL URLWithString:@"twitter://"];
   [[UIApplication sharedApplication] openURL:url];   
}

If you meant html on a website you'd use <a href="twitter://">tap me to go to twitter</a> for the link.

URL Schemes are shown here and you can grab some more handy information about them too.

I'd probably recommend @Arab_Geek's solution though as it isn't that much of a trouble and it's giving back control to the user.

erran
  • 1,300
  • 2
  • 15
  • 36
1

Why don't you use Twitter integratation for iOS 5 (TWTweetComposeViewController) ?

AK_
  • 1,879
  • 4
  • 21
  • 30
0
NSURL * twitterURL = [NSURL URLWithString:@"twitter://"];
if([[UIApplication sharedApplication] canOpenURL:twitterURL])
    [[UIApplication sharedApplication] openURL:twitterURL];
thelaws
  • 7,991
  • 6
  • 35
  • 54