evenodd
evenodd

Reputation: 2126

Open Twitter app in html

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

Upvotes: 1

Views: 2569

Answers (3)

erran
erran

Reputation: 1320

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.

Upvotes: 2

thelaws
thelaws

Reputation: 8001

NSURL * twitterURL = [NSURL URLWithString:@"twitter://"];
if([[UIApplication sharedApplication] canOpenURL:twitterURL])
    [[UIApplication sharedApplication] openURL:twitterURL];

Upvotes: 0

AK_
AK_

Reputation: 2059

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

Upvotes: 1

Related Questions