Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting programmatically whether an app is installed on iPhone

I am in this situation where I have to display a button which says "Open myApp" (if myApp is installed on the device) or it says "Download myApp" (if myApp is not installed on the device) in an iphone app. To do this, I need to detect whether an app (with a known custom URL) has been installed on the device. How can I do this? Thanks in advance.

like image 256
Amarsh Avatar asked Sep 27 '10 23:09

Amarsh


People also ask

How can I tell when an app was installed on my iPhone?

You can find out when an application was downloaded on an iPhone by accessing download history. Press a 3D Touch to have shortcuts with one being purchased tab where you'll get app details. You can also go to the app store and find the “purchased tab” with a list from the recent to old ones.

How can I check if an app is installed from a Web page on an iPhone?

Show activity on this post. iOS Safari has a feature that allows you to add a "smart" banner to your webpage that will link either to your app, if it is installed, or to the App Store. You do this by adding a meta tag to the page.

How do you know if an app has been installed?

On your Android phone, open the Google Play store app and tap the menu button (three lines). In the menu, tap My apps & games to see a list of apps currently installed on your device.


1 Answers

UPDATED 8th January 2014 - 3 things you can do

I actually had to do this for a client again. They wanted users to be able to open their second app from the main app if it had been installed.

This is my finding. Use the canOpenURL method to check if an app is installed or/and then use the openURL method to

  1. Open the application installed on the iOS device
  2. Take the user to the app store directly pointing them to the app/your list of developer apps
  3. Take them to a website instead

All code samples available for each scenario

//Find out if the application has been installed on the iOS device
- (BOOL)isMyAppInstalled { 
    return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"nameOfMyApp:"]]; 
} 

- (IBAction)openOrDownloadApp { 
    //This will return true if the app is installed on the iOS device
    if ([self myAppIsInstalled]){
        //Opens the application
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"nameOfMyApp:"]]; 
    } 
    else { //App is not installed so do one of following:

        //1. Take the user to the apple store so they can download the app
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/nameOfMyApp"]]; 

        //OR

        //2. Take the user to a list of applications from a developer
        //or company exclude all punctuation and space characters. 
        //for example 'Pavan's Apps'
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/PavansApps"]];

        //OR

        //3. Take your users to a website instead, with maybe instructions/information
         [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.pavan.com/WhyTheHellDidTheAppNotOpen_what_now.html"]];

    } 
}

Choose one option, I've just spoiled you with choice. Choose one that fits your requirements. In my case I had to use all three options in different areas of the program.

like image 73
Pavan Avatar answered Oct 16 '22 08:10

Pavan