Launching application via URL scheme

Featured Image

Here I will try to explain how to make your application launch another application on the system. There will be a minimal code written for these feature like everything else in Objective C and Cocoa Touch framework. Application that have support for URL’s can be launched with a call to the UIApplication’s openURL:.

Everything will work fine if the URL is well formed and the application is properly registered. We’ll do that later. iPhone OS will take care of the rest. For example:

- (IBAction) someButton  {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://inchoo.net"]];
}

This code above will run Safari browser and our site will pop up. There is several predefined URL schemes for integrated iPhone OS applications such as Mail. If you decide that you want launch another application (for testing purpose) from your application, you must first register URL scheme of  application that is going to be launched. That is easy part of job. To register a custom URL scheme, just add a this in Info.plist.

infoplist1

When we have done that, we just implement this code in method that triggers our button from nib file.

- (IBAction) anotherButton  {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"myapp://"]];
}

And now we can launch this application from our application. This is very simple and easy to implement so try it!

11
Top

Care to rate this post?

Author

Ivan Kalaica

Ex. Inchooer

At Inchoo, Ivan Kalaica was an iOS SDK developer. He worked with us from 2008. to 2012.

Other posts from this author

Discussion 11 Comments

Add Comment
  1. This is right down the alley I’ve been aimlessly wandering down. I am a new developer and have a simple app that lists a group of stores and links to their websites. I want to add more functionality in the form of a ‘todo’ list. I have a separate app which is this todo list. Would I have to add the todo list app to the Store App Folder then add a button. Then add the above code AppDelegate page?

    -(IBAction) todoButton {

    [[UIApplication shareApplication] openURL:[NSURL URLWithString:@"todo://"]];

    }

    I set up the CFBundleURLName and the scheme. Scheme= todo. Is this unheard of?

  2. Ivan Kalaica

    Hello Duane Amos,

    To be honest I did not fully understand your question but here is link where you can find all about launching application via URL scheme. Hope this helps!

  3. My basic question is…can I put an other app (.xcodeproj) inside my Resources folder and launch it!

  4. Ivan Kalaica

    Simple answer – nope. :-)

  5. Great, helpful for my idea :)

  6. noman soofi

    i want to launch quicktime player when a button clicked in my iphone application and passed a rtsp url to the quicktime player.

    how to do that ?

  7. Dee

    Is there any other way to launch an application with out using this URL Scheme ?? I mean just by knowing its name .. ??

  8. Amit Chowdhury

    Please can any one tell me how to image share instagram with custom url scheme use.

  9. Saturnsnoopy

    Is there any way to launch native iPhone application in webview without leaving the current application?

    The following code forces me to existing the current application when I clicked on it. I want to stay in the current apps while open other application:

    if ([[URL scheme] isEqualToString:@”MyApp”]) {
    [[UIApplication shareApplication] openURL:URL];
    }

  10. Ravi Bukka

    Hi Ivan,

    I am having two applications 1) testOne and 2) testTwo,

    And i have followed all the steps which you mentioned above to lauch testOne app from testTwo app (i am trying in simulator). I have written the below piece of code to launch testOne app.

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"testOne://"]];

    But it is not launching testOne app at all. Please help me in this.

  11. Si

    Hi does anyone know the scheme for the Apple in built Camera?
    Cheers.

Add Your Comment

Please wrap all source codes with [code][/code] tags.
Top