I want to redirect user to my App\'s Facebook page, so I have the following code:
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString: @\"ht
It seems that since the last answer Facebook have changed the scheme for pages (profile is same as before)
the page_id
is now the part of URL query.
So in order to redirect to fb app, the url has to be in the format:
fb://page/?id=your_page_numeric_id
Also make sure to whitelist fb
scheme in your apps Info.plist
LSApplicationQueriesSchemes
fb
In case there will be any further modifications or you don't know your facebook page's page_id
, you can extract the precise iOS fb
URL from your Facebook web page source.
al:ios:url
You should be able to find:
Copying this URL into your app and then calling:
guard let facebookURL = NSURL(string: "fb://page/?id=your_page_numeric_id") else {
return
}
if (UIApplication.sharedApplication().canOpenURL(facebookURL)) {
UIApplication.sharedApplication().openURL(facebookURL)
} else {
guard let webpageURL = NSURL(string: "http://facebook.com/yourPage/") else {
return
}
UIApplication.sharedApplication().openURL(webpageURL)
}
should do the job...