Reputation: 6834
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
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
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