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!

Interested in hiring us?

Have a chat with us. You would be surprised how small changes can make your business even more successful.


12 comments

  1. 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.

  2. 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];
    }

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

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

  5. 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 ?

  6. 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?

    1. 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!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.