Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a facebook link by native Facebook app on iOS

If the native Facebook app is installed on the iPhone. How do I open a facebook link into the native Facebook app from my app. In the case of opening by Safari, the link is same as:

http://www.facebook.com/AlibabaUS

Thank you.

like image 603
vietstone Avatar asked May 02 '12 14:05

vietstone


People also ask

Is Facebook iOS app native?

Originally, Facebook only developed React Native to support iOS. However, with it's recent support of the Android operating system, the library can now provide mobile UIs for both platforms.


2 Answers

Here are some schemes the Facebook app uses, there are a ton more on the source link:

Example

NSURL *url = [NSURL URLWithString:@"fb://profile/<id>"]; [[UIApplication sharedApplication] openURL:url]; 

Schemes

fb://profile – Open Facebook app to the user’s profile

fb://friends – Open Facebook app to the friends list

fb://notifications – Open Facebook app to the notifications list (NOTE: there appears to be a bug with this URL. The Notifications page opens. However, it’s not possible to navigate to anywhere else in the Facebook app)

fb://feed – Open Facebook app to the News Feed

fb://events – Open Facebook app to the Events page

fb://requests – Open Facebook app to the Requests list

fb://notes – Open Facebook app to the Notes page

fb://albums – Open Facebook app to Photo Albums list

If before opening this url you want to check wether the user fas the facebook app you can do the following (as explained in another answer below):

if ([[UIApplication sharedApplication] canOpenURL:nsurl]){     [[UIApplication sharedApplication] openURL:nsurl]; } else {     //Open the url as usual } 

Source

http://wiki.akosma.com/IPhone_URL_Schemes#Facebook

like image 54
WrightsCS Avatar answered Oct 14 '22 16:10

WrightsCS


Just use https://graph.facebook.com/(your_username or page name) to get your page ID and after you can see all the detain and your ID

after in your IOS app use :

 NSURL *url = [NSURL URLWithString:@"fb://profile/[your ID]"];  [[UIApplication sharedApplication] openURL:url]; 
like image 24
Romano401 Avatar answered Oct 14 '22 17:10

Romano401