AlvinfromDiaspar
AlvinfromDiaspar

Reputation: 6834

How to open an https Facebook page from iOS device?

Im trying to open my Facebook app page from iPhone. Im using this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.facebook.com/(my page name)"]];

Unfortunately, this redirects to https protocol, and because of that the device is unable to open the page.

What can I do to open this page?

Upvotes: 0

Views: 879

Answers (2)

bllakjakk
bllakjakk

Reputation: 5065

You are mistaken by using page name instead of page ID. You should use something like below:

NSURL *facebookURL = [NSURL URLWithString:@"fb://profile/{pageid}"];
if ([[UIApplication sharedApplication] canOpenURL:facebookURL]) {
    [[UIApplication sharedApplication] openURL:facebookURL];
} else {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@""https://www.facebook.com/{pageid}"]];
}

[If desired]: You should check the availability of installed facebook app to open the page, as shown in the above code sample.

Upvotes: 1

Anbu.Karthik
Anbu.Karthik

Reputation: 82756

pass your Page ID - xxxxxx not the page Name

 [UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb://profile/herepassyourPageID"]];  

or

[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.facebook.com/herepassyourPageID (id, not name)"]];  

Upvotes: 1

Related Questions