Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Facebook application from my app

Can someone tell the URL schemes to open the Facebook application from my app?

like image 792
kazui Avatar asked Sep 06 '15 12:09

kazui


1 Answers

Use fb://.

canOpenURL returns a BOOL value indicating whether or not the URL’s scheme can be handled by some app installed on the device. If canOpenURL returns YES then the application is present on the device. If the user has Facebook installed on their device we open it. If the user does not have Facebook installed we open the page through a link, which will launch Safari.

// Check if FB app installed on device
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) {
   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb://profile/355356557838717"]];
}
else {
   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.facebook.com/DanielStormApps"]];
}

Check out iPhone URL Schemes for a list of what else you can achieve via URL Schemes.

Also, starting at iOS 9 you must include LSApplicationQueriesSchemes in your info.plist.

enter image description here

like image 168
Daniel Storm Avatar answered Sep 28 '22 07:09

Daniel Storm