Opening external links/apps

Overview

External links can be triggered from JavaScript/TypeScript (which can also be used to open external apps), and some other actions can also be triggered such as making a phone call or drafting an SMS to a specified recipient.

The following syntax should be used in a JavaScript function (that is called when a button is pressed, for example):

return external.uri('http://www.google.com');
return external.call('0721234567');
return external.sms('0721234557');

Opening the platform's native maps application is a common use case for displaying locations or showing turn-by-turn navigation instructions. The Maps Helpers make it easy to do this in a platform-independent way.

external.maps.display()

The display() function opens a map at the given location be it a string address, location object or coordinates.

external.maps.display('10 Downing Street, London, UK');
external.maps.display(view.location);
external.maps.display('-33.9543704,18.397858');

external.maps.navigate()

The navigate() function starts turn-by-turn navigation. By default it navigates from the device's current location to the given destination. To navigate from a different start location, pass in two parameters: the first being the start address and the second the destination. e.g. external.maps.navigate(start, destination). Similar to display(), start and destination locations can either be a string address, location object or coordinates.

external.maps.navigate(
  '10 Downing Street, London, UK', 'Place du Luxembourg, European Quarter of Brussels, Belgium'
);
external.maps.navigate(view.delivery_location);
external.maps.display('-33.9543704,18.397858');

Opening an External App

By utilizing URL handlers that are available on a mobile device, it is possible to launch external apps.

In the following example, we open the App Store on iOS and display the JourneyApps application, using the itms:// URL handler that is available on iOS.

View XML:

<button label="JourneyApps on iTunes" on-press="openiTunesLink" validate="false" />

View JavaScript:

function openiTunesLink() {
  return external.uri('itms://itunes.apple.com/us/app/journey-launcher/id642377374?mt=8&uo=4');
}

In some cases, it may be necessary to tailor your links depending on which mobile OS the user is using (iOS or Android). For this purpose, the global journey.platform property can be used, which will have a value of either "iOS" or "Android" depending on the OS. The value can also be "Web" if using the app in the browser.

To make our previous example work on both Android and iOS, we would use:

if (journey.device.platform == 'iOS') {
  return external.uri('itms://itunes.apple.com/us/app/journey-launcher/id642377374?mt=8&uo=4');
} else if (journey.device.platform == 'Android') {
  return external.uri('https://play.google.com/store/apps/details?id=com.embarkmobile.androidapp&hl=en&launch=true');
}

Open other Containers

Version compatibility

This feature was introduced in version 20.6.1 of the JourneyApps Container, and requires version 4.76.0 or greater of the JourneyApps Runtime.

You can open another container using its URL scheme.

Each container has a URL scheme, e.g. "journeyapps" or "acme".

To open for example a container with the scheme "acme", you can use the URL acme:///open. This can be done from normal web links, or using external.uri('acme:///open'). Notice the triple slashes.

This feature can be used to jump between Containers on the same device, or a quick way to launch an application. If the Container is already open in the background, it will be focused.

Last updated