How to detect if Facebook app is installed on iOS?

17,358

Solution 1

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

if (isInstalled) {

} else {

}

Solution 2

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  
}
Share:
17,358

Related videos on Youtube

Tom Kincaid
Author by

Tom Kincaid

Updated on October 31, 2020

Comments

  • Tom Kincaid
    Tom Kincaid over 3 years

    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.

  • rmaddy
    rmaddy over 10 years
    Don't encourage duplicate questions.
  • Tommy Devoy
    Tommy Devoy over 10 years
    I wrote it before I saw the closure votes. Good call, I'll vote as well
  • Borut Tomazin
    Borut Tomazin over 8 years
    You also need to include LSApplicationQueriesSchemes key into info.plist for iOS 9 with value "fb".