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):
Navigating and Displaying Locations With the Maps Helper
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.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.
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:
View JavaScript:
Platform-Specific Links
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:
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