# 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):

```javascript
return external.uri('http://www.google.com');
```

```javascript
return external.call('0721234567');
```

```javascript
return external.sms('0721234557');
```

### 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.

```javascript
external.maps.display('10 Downing Street, London, UK');
```

```javascript
external.maps.display(view.location);
```

```javascript
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.

```javascript
external.maps.navigate(
  '10 Downing Street, London, UK', 'Place du Luxembourg, European Quarter of Brussels, Belgium'
);
```

```javascript
external.maps.navigate(view.delivery_location);
```

```javascript
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:

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

View JavaScript:

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

### 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:

```javascript
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

{% hint style="info" %}
**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.
{% endhint %}

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.journeyapps.com/reference/build/integration/opening-external-links-apps.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
