Open link to Facebook page from iOS app

medvedNick

I want to redirect user to my App's Facebook page, so I have the following code:

[[UIApplication sharedApplication] openURL:
    [NSURL URLWithString: @"https://facebook.com/myAppsPage"]];

this works great, if there is no Facebook app on device. Then the link opens in Safari.

If there is Facebook app installed on device, then after executing above code Facebook app opens, but it is showing users timeline, not my app's page. I tried to change link to @"fb://pages/myAppsPage" and to @"fb://profile/myAppsPage, but this again opened users timeline.

So, my question is: how can I open my apps page in safari, if there is no Facebook app, or in Facebook app, if the one is installed.

Sean Kladek

You have to use the facebook ID for the given page rather than the vanity URL. To get the pages ID, enter your page's vanity name at the following URL and copy the value for "id":

https://graph.facebook.com/yourappspage

Once you have the id, you can set up the method to check if FB is installed using the canOpenURL method and serve the appropriate content for both states:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Open facebook page link in browser or native app correctly IOS cordova

Open a facebook link by native Facebook app on iOS

Open app from Facebook link

How to open facebook page in native iOS app

Open Facebook page from Android app?

Open Facebook Messenger from iOS app

Open link with facebook app in android

How to open the Google play app from a shared Facebook link?

How to open a specific facebook page from my app?

is possible in codenameone app a Link to open the facebook app?

Open facebook page into facebook application Ios + ionic

Open Facebook Page in Facebook App (if installed) on Android

Open a link from web app to new Safari window in iOS 8

How to open someone's profile page with their app scope ID in native iOS Facebook app

How to open a specific PayPal link in the PayPal iOS app from my iOS app

Can't link app to Facebook page

Open my app from a link

Dynamic link on ios open black page

Is there any way to force a link to open in Chrome from Facebook's in-app browser?

Open a shared link in facebook to open in native app if installled in iphone

Can't open my app from facebook in-app browser iOS 9

xamarin forms app link - open PCL view from ios app delegate

Facebook Android app link opens Facebook page instead of Play Store

Link to open facebook app if app exists, else webpage

iOS: apple universal link if app is not open?

is it possible to open a link from ionic cordova app from ios platform in microsoft-edge browser

Link to another page from App page not working

how to share a Photo Or link on facebook wall without using FBSDKShareDialog from native ios app

Open Facebook Post in Facebook App From iPhone App