Developers Knowledge Base

Mobile and field solutions function as an extension of the overall enterprise, and include the ability to access, create, review and update geospatial data and asset information in real-time in the field.
Showing results for 
Search instead for 
Do you mean 

Using Custom URL schemes

by Technical Evangelist on ‎06-22-2016 05:53 AM (754 Views)

Description

 

Custom URL schemes can be used for communication between applications or in order to launch the application from a URL. The URL can be placed i.e. on a website or in QR code.

 

Adding a custom URL scheme to a project

 

If you want to learn how to create project with your own custom URL scheme please visit Create project article. In brief, you can provide the urlScheme parameter to the `createproject` command which determines what your scheme is:

 

--urlScheme=yoururlscheme

Once the project is created you can always edit this value by changing a value of the URL_SCHEME property in the config.xml file. Thisfile is located in the root folder of the project.

  

 <variable name="URL_SCHEME" value="newurlscheme" />

  

 Usage

 

Your application can be launched by using the links as the following one:

 

<a href="yoururlscheme://">SDK Application</a>

Provided you want to allow opening your SDK based application from another Cordova based application you should use inAppBrowser plugin. This is necessary in order to avoid 'protocol not supported' error:

 

<button onclick="window.open('yoururlscheme://', '_system')">SDK Application</button>

 

If you need, you can pass any parameters in this URL. For example if you want to pass coordinates to the application, you can use:

 

<a href="yoururlscheme://?x=51&y=19">Open my app</a>

 

If you pass some data in the URL you need to have a way of accessing this data. This URL is accesible in handleOpenUrl method that can be found in the index.html file.

 

function handleOpenURL(url) {
  console.log("received url: " + url);
}

 

Overview