0

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?

AlvinfromDiaspar
  • 6,611
  • 13
  • 75
  • 140

2 Answers2

1

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)"]];  
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
1

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.

bllakjakk
  • 5,045
  • 1
  • 18
  • 28