Determine if an app exists and launch that app on iOS

To check if an app is installed (e.g. Clear):

BOOL installed = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"clearapp://"]];

To open that app:

BOOL success = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"clearapp://"]];

There is a script like the following.

<script type="text/javascript">
function startMyApp()
{
  document.location = 'yourAppScheme://';
  setTimeout( function()
  {
      if( confirm( 'You do not seem to have Your App installed, do you want to go download it now?'))
      {
        document.location = 'http://itunes.apple.com/us/app/yourAppId';
      }
  }, 300);
 }
</script>

Calling this script from the web (<a href="#" onclick="startMyApp()">Try to start MyApp</a>), you can determine if your app with scheme "yourAppScheme" is installed on the device or not.

The App will launch if it is installed on the device and "yourAppScheme" is registered in it. If the app is not installed you can suggest the user to install this app from iTunes.


Doable, but tricky.

Launching installed apps, like the FB or Twitter apps, is done using the Custom URL Scheme. These can be used both in other apps as well as on web sites.

Here's an article about how to do this with your own app.

Seeing if the URL is there, though, can be tricky. A good example of an app that detects installed apps is Boxcar. The thing here is that Boxcar has advanced knowledge of the custom URL's. I'm fairly (99%) certain that there is a canOpenURL:, so knowing the custom scheme of the app you want to target ahead of time makes this simple to implement.

Here's a partial list of some of the more popular URL's you can check against.

There is a way to find out the custom app URL : https://www.amerhukic.com/finding-the-custom-url-scheme-of-an-ios-app

But if you want to scan for apps and deduce their URL's, it can't be done on a non-JB device.

Here's a blog post talking about how the folks at Bump handled the problem.