Check if app is installed, and if so open it?

Discussion in 'iOS Programming' started by Danneman101, May 17, 2009.

  1. Danneman101 macrumors 6502

    Joined:
    Aug 14, 2008
    #1
    Is it possible to check if another app is installed, and if so open it. And if not, go to iTunes to get it?

    How would I go about doing that?

    At the moment I know how to open Safari from my obj-c code using:
    Code:
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.mysite.com"]];
    
     
  2. fishkorp macrumors 68020

    fishkorp

    Joined:
    Apr 10, 2006
    Location:
    Ellicott City, MD
    #2
    You can't have your app know which other apps are installed with the SDK (you can if you Jailbreak).

    If an app has a registered URL Scheme, then you can launch an app that way, TwitterFon does this, TeeShot I believe does this. But I'm not sure what happens if you try to launch via an app URL Scheme if the app is not installed.
     
  3. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #3
    Sorry to be unclear: Actually, Im not trying to find any other program. I have a series of apps that should open one after another. And if the iphone recognises that the app isnt installed, it should go to itunes to get it/check it out. So I should be able to define which program Im looking for in advance.

    Is it more feasible that way?
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    The only way to open another app is if that app has registered a URL schema. If that app is not installed (so the schema for that app is not registered) then when you use openURL: it should fail (I hope). This will tell you the other app is not installed.
     
  5. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
  6. drivefast macrumors regular

    Joined:
    Mar 13, 2008
    #6
    as of 3.0, you have the .canOpenURL property of the UIApplication, which tells you upfront whether your openURL attempt will be successful or not. this way you can keep your application alive.
     
  7. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #7
    Will probably be a welcome addition. However, it was pretty easy getting it working with URL Schemes - very easy, in fact :)
     

Share This Page