Jake Ortiz
Jake Ortiz

Reputation: 513

How open facebook and twitter on a specific page in iOS

Which is the line of code to open facebook and twitter displaying a given page?

tried with this for Facebook

NSURL *target = [[NSURL alloc] initWithString:@"fb://profile/WindyCityCrossFit"]; [[UIApplication sharedApplication] openURL:target];

but it just taks me to my news feed page. Twitter haven't given me any results either.

Upvotes: 0

Views: 1278

Answers (2)

Stephen
Stephen

Reputation: 1446

Facebook:

NSURL *url = [NSURL URLWithString:@"fb://profile/130936560286785"]; [[UIApplication sharedApplication] openURL:url];

Twitter:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://user?screen_name=MyTwitterID"]];

Upvotes: 2

Clev3r
Clev3r

Reputation: 1588

This should get you to facebook, though I'm not sure about twitter.

NSString *urlString = <your url>;
NSString *title = <your message>;
NSString *shareUrlString = [NSString stringWithFormat:@"http://www.facebook.com/sharer.php?u=%@&t=%@", urlString , title];
shareUrlString = [shareUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            NSURL *url = [[NSURL alloc] initWithString:shareUrlString];
            [[UIApplication sharedApplication] openURL:url];

Upvotes: 0

Related Questions