21

On iOS, you can launch the Facebook app and link to a profile by opening a url like this: fb://profile/12345

The only problem is that if the Facebook app isn't installed, nothing happens.

Is there a way to detect if the app is installed or if the url scheme fb:// is supported?

This would apply broadly to other apps like Twitter as well.

Tom Kincaid
  • 4,887
  • 6
  • 47
  • 72

2 Answers2

51
BOOL isInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]

if (isInstalled) {

} else {

}
Nikos M.
  • 13,685
  • 4
  • 47
  • 61
7

Try just using the canOpenURL: function

NSURL *fbURL = [NSURL URLWithString:@"fb://"];//or whatever url you're checking

if ([[UIApplication sharedApplication] canOpenURL:fbURL])
{
  //open it etc  
}
Tommy Devoy
  • 13,441
  • 3
  • 48
  • 75