Cordova Custom URL Scheme Handling

For an iOS app, you can add a URL Scheme handler in your app's Info.plist so that your app launches when another iOS app (like Mobile Safari) launches a URL with your custom scheme.

  1. Register your custom scheme in your app's Info.plist: the instructions are here

  2. In your JavaScript, add a global function handleOpenURL which just takes one parameter, which will be a string containing the URL that was launched. Add your code to parse and handle the URL in that global function. This function will be called always if your app was launched from the custom scheme.

     function handleOpenURL(url) {
         // TODO: parse the url, and do something 
     }
    

IMPORTANT NOTE:

You cannot launch any interactive features like alerts in the handleOpenURL code, if you do, your app will hang. Similarly, you should not call any Cordova APIs in there, unless you wrap it first in a setTimeout call, with a timeout value of zero:

    function handleOpenURL(url) {
         // TODO: parse the url, and do something 
         setTimeout(function() {
             // TODO: call some Cordova API here
         }, 0);
    }