An open API service indexing awesome lists of open source software.

https://github.com/cap-go/capacitor-launch-navigator

Capacitor plugin which launches native route navigation apps for Android, iOS
https://github.com/cap-go/capacitor-launch-navigator

capacitor capacitor-plugin

Last synced: about 1 month ago
JSON representation

Capacitor plugin which launches native route navigation apps for Android, iOS

Awesome Lists containing this project

README

          

# @capgo/capacitor-launch-navigator
Capgo - Instant updates for capacitor


➡️ Get Instant updates for your App with Capgo


Missing a feature? We’ll build the plugin for you 💪


Capacitor plugin for launching navigation apps to navigate to a destination.

This plugin is a Capacitor port of the popular phonegap-launch-navigator plugin, supporting navigation with latitude/longitude coordinates only (no address support - use [@capgo/capacitor-nativegeocoder](https://github.com/Cap-go/capacitor-nativegeocoder) for address geocoding).

## Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/launch-navigator/

## Compatibility

| Plugin version | Capacitor compatibility | Maintained |
| -------------- | ----------------------- | ---------- |
| v8.\*.\* | v8.\*.\* | ✅ |
| v7.\*.\* | v7.\*.\* | On demand |
| v6.\*.\* | v6.\*.\* | ❌ |
| v5.\*.\* | v5.\*.\* | ❌ |

> **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

## Install

```bash
npm install @capgo/capacitor-launch-navigator
npx cap sync
```

## iOS Setup

Add URL schemes to your `Info.plist` to detect installed navigation apps:

```xml
LSApplicationQueriesSchemes

comgooglemaps
waze
citymapper
navigon
transit
yandexnavi
uber
tomtomgo
com.sygic.aura
here-route
moovit
lyft
mapsme
cabify
baidumap
iosamap
99app

```

## Android Setup

**No additional setup required!** The plugin automatically handles Android 11+ (API level 30+) package visibility and is fully backward compatible with earlier Android versions.

The plugin's manifest includes `` declarations for all supported navigation apps, which are automatically merged into your app's manifest during the build process. On Android 10 and below, the `` element is safely ignored.

For reference: Package queries included in the plugin

The following navigation apps are declared in the plugin's manifest:

```xml













```

**Compatibility:**
- **Android 11+ (API 30+):** Queries are required and enforced for package visibility
- **Android 10 and below (API 29-):** Queries element is ignored; app detection works without restrictions

This ensures the plugin works correctly across all Android versions from API 24+ without any code changes.

## Usage

```typescript
import { LaunchNavigator, IOSNavigationApp, AndroidNavigationApp, TransportMode } from '@capgo/capacitor-launch-navigator';

// Navigate to a location using default app
await LaunchNavigator.navigate({
destination: [37.7749, -122.4194] // San Francisco coordinates
});

// Navigate with options
await LaunchNavigator.navigate({
destination: [37.7749, -122.4194],
options: {
start: [37.7849, -122.4094], // Starting point
app: 'google_maps', // Specific app to use
transportMode: TransportMode.DRIVING
}
});

// Check if an app is available
const { available } = await LaunchNavigator.isAppAvailable({
app: IOSNavigationApp.GOOGLE_MAPS
});

// Get list of available navigation apps
const { apps } = await LaunchNavigator.getAvailableApps();
apps.forEach(app => {
console.log(`${app.name} is ${app.available ? 'available' : 'not installed'}`);
});
```

## Important Notes

- **Coordinates Only**: This plugin only accepts latitude/longitude coordinates for navigation. Address strings are not supported.
- **Address Geocoding**: If you need to convert addresses to coordinates, use [@capgo/capacitor-nativegeocoder](https://github.com/Cap-go/capacitor-nativegeocoder).

## Supported Navigation Apps

### iOS
- Apple Maps
- Google Maps
- Waze
- Citymapper
- Garmin Navigon
- Transit App
- Yandex Navigator
- Uber
- TomTom
- Sygic
- HERE Maps
- Moovit
- Lyft
- MAPS.ME
- Cabify
- Baidu Maps
- Gaode Maps
- 99 Taxi

### Android
- Google Maps
- Waze
- Citymapper
- Uber
- Yandex Navigator
- Sygic
- HERE Maps
- Moovit
- Lyft
- MAPS.ME
- Cabify
- Baidu Maps
- Gaode Maps

## API

* [`navigate(...)`](#navigate)
* [`isAppAvailable(...)`](#isappavailable)
* [`getAvailableApps()`](#getavailableapps)
* [`getSupportedApps()`](#getsupportedapps)
* [`getDefaultApp()`](#getdefaultapp)
* [`getPluginVersion()`](#getpluginversion)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
* [Enums](#enums)

Main plugin interface

### navigate(...)

```typescript
navigate(options: { destination: [number, number]; options?: NavigateOptions; }) => Promise
```

Navigate to a location using latitude and longitude

| Param | Type | Description |
| ------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| **`options`** | { destination: [number, number]; options?: NavigateOptions; } | Navigation options with destination coordinates |

--------------------

### isAppAvailable(...)

```typescript
isAppAvailable(options: { app: IOSNavigationApp | AndroidNavigationApp | string; }) => Promise<{ available: boolean; }>
```

Check if a specific navigation app is available

| Param | Type | Description |
| ------------- | ----------------------------- | --------------------------------- |
| **`options`** | { app: string; } | Options containing app identifier |

**Returns:** Promise<{ available: boolean; }>

--------------------

### getAvailableApps()

```typescript
getAvailableApps() => Promise<{ apps: AvailableApp[]; }>
```

Get list of available navigation apps on the device

**Returns:** Promise<{ apps: AvailableApp[]; }>

--------------------

### getSupportedApps()

```typescript
getSupportedApps() => Promise<{ apps: string[]; }>
```

Get list of supported apps for the current platform

**Returns:** Promise<{ apps: string[]; }>

--------------------

### getDefaultApp()

```typescript
getDefaultApp() => Promise<{ app: string; }>
```

Get the name of the default app for navigation

**Returns:** Promise<{ app: string; }>

--------------------

### getPluginVersion()

```typescript
getPluginVersion() => Promise<{ version: string; }>
```

Get the native Capacitor plugin version

**Returns:** Promise<{ version: string; }>

--------------------

### Interfaces

#### NavigateOptions

Options for navigation

| Prop | Type | Description |
| --------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------- |
| **`start`** | [number, number] | Starting location coordinates [latitude, longitude] |
| **`startName`** | string | Starting location name |
| **`destinationName`** | string | Destination name (will be ignored since we only support coordinates) |
| **`transportMode`** | TransportMode | Transport mode |
| **`app`** | string | Specific app to launch (if not specified, will use default or prompt) |
| **`launchMode`** | LaunchMode | Launch mode |
| **`extras`** | Record<string, any> | Additional parameters specific to certain apps |
| **`enableDebug`** | boolean | Enable debug logging |

#### AvailableApp

Result of checking app availability

| Prop | Type | Description |
| --------------- | -------------------- | ------------------------------------------ |
| **`app`** | string | App identifier |
| **`name`** | string | Display name of the app |
| **`available`** | boolean | Whether the app is available on the device |

### Type Aliases

#### Record

Construct a type with a set of properties K of type T

{
[P in K]: T;
}

### Enums

#### TransportMode

| Members | Value |
| --------------- | ------------------------ |
| **`DRIVING`** | 'driving' |
| **`WALKING`** | 'walking' |
| **`BICYCLING`** | 'bicycling' |
| **`TRANSIT`** | 'transit' |

#### IOSNavigationApp

| Members | Value |
| ---------------------- | ----------------------------- |
| **`APPLE_MAPS`** | 'apple_maps' |
| **`GOOGLE_MAPS`** | 'google_maps' |
| **`WAZE`** | 'waze' |
| **`CITYMAPPER`** | 'citymapper' |
| **`GARMIN_NAVIGON`** | 'garmin_navigon' |
| **`TRANSIT_APP`** | 'transit_app' |
| **`YANDEX_NAVIGATOR`** | 'yandex' |
| **`UBER`** | 'uber' |
| **`TOMTOM`** | 'tomtom' |
| **`SYGIC`** | 'sygic' |
| **`HERE_MAPS`** | 'here' |
| **`MOOVIT`** | 'moovit' |
| **`LYFT`** | 'lyft' |
| **`MAPS_ME`** | 'mapsme' |
| **`CABIFY`** | 'cabify' |
| **`BAIDU`** | 'baidu' |
| **`GAODE`** | 'gaode' |
| **`TAXI_99`** | '99taxi' |

#### AndroidNavigationApp

| Members | Value |
| ----------------- | -------------------------- |
| **`GOOGLE_MAPS`** | 'google_maps' |
| **`WAZE`** | 'waze' |
| **`CITYMAPPER`** | 'citymapper' |
| **`UBER`** | 'uber' |
| **`YANDEX`** | 'yandex' |
| **`SYGIC`** | 'sygic' |
| **`HERE_MAPS`** | 'here' |
| **`MOOVIT`** | 'moovit' |
| **`LYFT`** | 'lyft' |
| **`MAPS_ME`** | 'mapsme' |
| **`CABIFY`** | 'cabify' |
| **`BAIDU`** | 'baidu' |
| **`GAODE`** | 'gaode' |

#### LaunchMode

| Members | Value |
| ------------------ | --------------------------- |
| **`MAPS`** | 'maps' |
| **`TURN_BY_TURN`** | 'turn_by_turn' |
| **`GEO`** | 'geo' |

This plugin was inspired by the work of https://github.com/dpa99c/phonegap-launch-navigator