0
votes

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?

2

2 Answers

1
votes

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)"]];  
1
votes

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.