Launching application via URL scheme

Launching application via URL scheme

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:@"https://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!

You made it all the way down here so you must have enjoyed this post! You may also like:

Apple push notifications from Magento Darko Goles
Darko Goles, | 5

Apple push notifications from Magento

Magento API v2 SOAP demystified Darko Goles
Darko Goles, | 39

Magento API v2 SOAP demystified

Develop your own Magento mobile application Ivica Tadic
Ivica Tadic, | 50

Develop your own Magento mobile application

18 comments

  1. There is a simple connectivity in launching application on another application in iPhone. It is very interesting technique in iphone.application have support URL for iPhone services.It is very best knowledge about launching application.here is the yahoo mail customer support number marking in iPhone application basically for ios developer.

  2. ‘sharedApplication’ is unavailable: not available on iOS (App Extension) –
    there is error…… Use view controller based solutions where appropriate instead.

  3. Hi,

    I am stuck in filling SDK Domain in Linkedin. i am doing Hybrid Application by using cordova. Since Im build from Javascript, so i have to fill in Linkedin SDK domain for redirect URL in javascript tab correct? Do you know how to fill in SDK Domain from Javascript in Linkedin developer site. It prompt me have to insert https or http. But based on the URL schemes here. If i key in myapp. Linkedin will promt me “SDK Domain URLs must be HTTP or HTTPS.” I have tried insert mine URL identifier as yours “http://mychoo.inchoo.com”. It said invalid redirect url. Hopefully could get somebody help.

  4. how can we do the same by clicking on link in emails. For eg i have a link in my mail like “http://myapp://” clicking on it,browser tries to render “http://myapp/” i.e. without the colon, how to fix that

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

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

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

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

  9. 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> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.