cordova plugin add https://github.com/Telerik-Verified-Plugins/Custom-URL-scheme --variable URL_SCHEME=mycoolapp (or something cooler)
appbuilder plugin add "Custom URL Scheme"
The Custom URL Scheme plugin allows your app to be launched by a URL scheme.
You will associate your app with a URL scheme which must be unique on the users device. Here are some hints to avoid trouble:
The most robust way to test your URL scheme is by kicking up a basic web page with a few links, like <a href="myapp://mypage.html?foo=bar">launch my app<a>. Note that typing your URL scheme in the device browser doesn't work on most devices.
If you other app is also a Cordova app, you need to install the InAppBrowser plugin. Then create a link like this one:
<a onclick="window.open('mycoolapp://foo=bar', '_system')">Launch mycoolapp</a>
So you've launched your app via your shiny URL scheme and you've passed in a path and some params. How do you retrieve those, so you can for example send the user to a specific page (deep linking)?
On iOS the device will invoke a Javascript function called 'handleOpenURL'. If it's present in the 'window' scope of your app, any code in that function will run. On Android the plugin needs to invoke the native code to see if there is a pending 'Intent' and if there is, the plugin will invoke the 'handleOpenURL' function. So all you need to do is provide that function in the global (window) scope inside a <script> block or .js file which is always included in any page of your app:
// If you need to access Cordova functions inside this function, make sure 'deviceready' has fired function handleOpenURL(url) { // Wrapping in a little timeout, so it doesn't interfere with other app setup stuff setTimeout(function() { // The url will include your URL scheme. // Extract the path and params like you'd do with any other URL. alert("App launch URL:\n" + url); }, 300); };
To get you going quickly you can clone our demo app by clicking the 'Try Plugin in AppBuilder' button at the top of this page.
If you want to add this plugin to your existing project, browse to 'plugins' via 'Properties' or 'Manage packages', and locate this plugin in 'Plugins Marketplace' list.
After installation of the plugin, go to the list of installed plugins and configure the URL_SCHEME variable for this plugin.