kazui kazui - 1 year ago 70
iOS Question

Open Facebook application from my app

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download