A React Native module for launching today's most popular navigation/ride apps to navigate to a destination.
Platforms: Android and iOS.
Key features:
Launch Navigator functionality is also available as a Cordova/Phonegap plugin.
I dedicate a considerable amount of my free time to developing and maintaining my Open Source software. To help ensure this module is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this software in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes.
Table of Contents
navigate()
is passed a location type which the selected app doesn't support, the error callback will be invoked if:
enableGeocoding: false
in the options objectThe module currently supports launching the following navigation apps:
Android
geo:
URI schemeiOS
This module is a work in progress. I'd like it to support launching of as many popular navigation apps as possible.
If there's another navigation app which you think should be explicitly supported and it provides a mechanism to externally launch it, open an issue containing a link or details of how the app should be invoked.
Don't just open an issue saying "Add support for Blah" without first finding out if/how it can be externally launched. I don't have time to research launch mechanisms for every suggested app, so I will close such issues immediately.
npm install --save react-native-launch-navigator
For iOS only:
cd ios && pod install
On iOS, for each installed navigation app you want your app to be able to launch, you must manually whitelist its custom URL scheme in your app's Info.plist
.
Note: this is required since React Native v0.60 added autolinking and removed support for postlink hook scripts which made it possible to automate this step.
Add the URL schemes for the navigation apps you want to support to the LSApplicationQueriesSchemes
key in your Info.plist
:
App | Scheme |
---|---|
City Mapper | citymapper |
Google Maps | comgooglemaps |
Garmin Navigon | navigon |
Transit App | transit |
Waze | waze |
Yandex Navigator | yandexnavi |
Uber | uber |
Tomtom | tomtomhome |
Sygic | com.sygic.aura |
HERE Maps | here-route |
Moovit | moovit |
Lyft | lyft |
MAPS.ME | mapsme |
Cabify | cabify |
Baidu Maps | baidumap |
99 Taxi | taxis99 |
Gadode | iosamap |
The full list of URL schemes above can be found in the example project's Info.plist
.
Import the module into your app:
import LaunchNavigator from 'react-native-launch-navigator';
On Android, don't forget to set your Google API key:
if(Platform.OS === "android") LaunchNavigator.setGoogleApiKey("your_api_key");
Uses default OS navigation app (Google Maps on Android / Apple Maps on iOS).
LaunchNavigator.navigate("London, UK")
.then(() => console.log("Launched navigator"))
.catch((err) => console.error("Error launching navigator: "+err));
LaunchNavigator.navigate("London, UK", {
start: "Manchester, UK"
})
.then(() => console.log("Launched navigator"))
.catch((err) => console.error("Error launching navigator: "+err));
Coordinates can be specified as a string or array
LaunchNavigator.navigate([50.279306, -5.163158], {
start: "50.342847, -4.749904"
})
.then(() => console.log("Launched navigator"))
.catch((err) => console.error("Error launching navigator: "+err));
let app = null;
LaunchNavigator.isAppAvailable(LaunchNavigator.APP.WAZE).then((isWazeAvailable) => {
if(isWazeAvailable){
app = LaunchNavigator.APP.WAZE;
}else{
console.warn("Waze not available - falling back to default navigation app");
}
LaunchNavigator.navigate("London, UK", {
app: app
});
.then(() => console.log("Launched navigator"))
.catch((err) => console.error("Error launching navigator: "+err));
});
if(Platform.OS === "android"){
platform = LaunchNavigator.PLATFORM.ANDROID;
}else if(Platform.OS == "ios"){
platform = LaunchNavigator.PLATFORM.IOS;
}
LaunchNavigator.getAppsForPlatform(platform).forEach((app) => {
console.log(LaunchNavigator.getAppDisplayName(app) + " is supported");
});
let apps = LaunchNavigator.getAvailableApps();
for(let app in apps){
console.log(LaunchNavigator.getAppDisplayName(app) + (apps[app] ? " is" : " isn't") +" available");
}
Different apps support different input parameters on different platforms. Any input parameters not supported by a specified app will be ignored.
The following table enumerates which apps support which parameters.
Platform | App | Dest | Dest name | Start | Start name | Transport mode | Free |
---|---|---|---|---|---|---|---|
Android | Google Maps (Map mode) | X | X | X | |||
Android | Google Maps (Turn-by-turn mode) | X | X | X | |||
Android | Waze | X | X | ||||
Android | CityMapper | X | X | X | X | X | |
Android | Uber | X | X | X | X | X | |
Android | Yandex | X | X | X | |||
Android | Sygic | X | X | X | |||
Android | HERE Maps | X | X | X | X | X | |
Android | Moovit | X | X | X | X | X | |
Android | Lyft | X | X | X | |||
Android | MAPS.ME | X | X | X | X | ||
Android | Geo: URI scheme | X | X | N/A | |||
Android | Cabify | X | X | X | X | X | |
Android | Baidu Maps | X | X[1] | X | X[1] | X | X |
Android | 99 Taxi | X | X | X | X | X | |
Android | Gaode Maps | X | X | X | X | X | X |
iOS | Apple Maps - URI scheme | X | X | X | X | ||
iOS | Apple Maps - MapKit class | X | X | X | X | X | X |
iOS | Google Maps | X | X | X | X | ||
iOS | Waze | X | X | ||||
iOS | Citymapper | X | X | X | X | X | |
iOS | Navigon | X | X | ||||
iOS | Transit App | X | X | X | |||
iOS | Yandex | X | X | X | |||
iOS | Uber | X | X | X | X | ||
iOS | Tomtom | X | X | ||||
iOS | Sygic | X | X | X | |||
iOS | HERE Maps | X | X | X | X | X | |
iOS | Moovit | X | X | X | X | X | |
iOS | Lyft | X | X | X | |||
iOS | MAPS.ME | X | X | X | X | ||
iOS | Cabify | X | X | X | X | X | |
iOS | Baidu Maps | X | X[1] | X | X[1] | X | X |
iOS | 99 Taxi | X | X | X | X | X | |
iOS | Gaode Maps | X | X | X | X | X | X |
[1]: Only supported when Start or Dest is specified as lat/lon (e.g. "50,-4")
Table columns:
Apps that support specifying transport mode.
Platform | App | Driving | Walking | Bicycling | Transit |
---|---|---|---|---|---|
Android | Google Maps (Turn-by-turn mode) | X | X | X | X |
Android | Sygic | X | X | ||
Android | MAPS.ME | X | X | X | X |
Android | Baidu Maps | X | X | X | X |
Android | Gaode Maps | X | X | X | X |
iOS | Apple Maps | X | X | ||
iOS | Google Maps | X | X | X | X |
iOS | Sygic | X | X | ||
iOS | MAPS.ME | X | X | X | X |
iOS | Baidu Maps | X | X | X | X |
iOS | Gaode Maps | X | X | X | X |
All of the module constants and functions should be referenced from the namespace used to import the module, for example:
import LaunchNavigator from 'react-native-launch-navigator';
let android = LaunchNavigator.PLATFORM.ANDROID;
Supported platforms:
LaunchNavigator.PLATFORM.ANDROID
LaunchNavigator.PLATFORM.IOS
Supported apps:
LaunchNavigator.APP.GEO
(Android) - invokes a native chooser, allowing users to select an app which supports the geo:
URI scheme for navigationLaunchNavigator.APP.GOOGLE_MAPS
(Android & iOS)LaunchNavigator.APP.WAZE
(Android & iOS)LaunchNavigator.APP.CITYMAPPER
(Android & iOS)LaunchNavigator.APP.UBER
(Android & iOS)LaunchNavigator.APP.APPLE_MAPS
(iOS)LaunchNavigator.APP.NAVIGON
(iOS)LaunchNavigator.APP.TRANSIT_APP
(iOS)LaunchNavigator.APP.YANDEX
(Android & iOS)LaunchNavigator.APP.TOMTOM
(iOS)LaunchNavigator.APP.SYGIC
(Android & iOS)LaunchNavigator.APP.HERE_MAPS
(Android & iOS)LaunchNavigator.APP.MOOVIT
(Android & iOS)LaunchNavigator.APP.LYFT
(Android & iOS)LaunchNavigator.APP.MAPS_ME
(Android & iOS)LaunchNavigator.APP.CABIFY
(Android & iOS)LaunchNavigator.APP.BAIDU
(Android & iOS)LaunchNavigator.APP.TAXIS_99
(Android & iOS)LaunchNavigator.APP.GAODE
(Android & iOS)Display names for supported apps, referenced by LaunchNavigator.APP
.
e.g. LaunchNavigator.APP_NAMES[LaunchNavigator.APP.GOOGLE_MAPS] == "Google Maps"
x
Transport modes for navigation:
LaunchNavigator.TRANSPORT_MODE.DRIVING
LaunchNavigator.TRANSPORT_MODE.WALKING
LaunchNavigator.TRANSPORT_MODE.BICYCLING
LaunchNavigator.TRANSPORT_MODE.TRANSIT
Launch modes supported by Google Maps on Android (see Google Maps launch modes):
LaunchNavigator.LAUNCH_MODE.MAPS
- Maps viewLaunchNavigator.LAUNCH_MODE.TURN_BY_TURN
- Navigation viewLaunchNavigator.LAUNCH_MODE.GEO
- Navigation view via geo:
URI schemeLaunch modes supported by Apple Maps on iOS (see Apple Maps launch modes:
LaunchNavigator.LAUNCH_MODE.URI_SCHEME
: use the URI scheme launch method. Default if not specified.LaunchNavigator.LAUNCH_MODE.MAPKIT
: use the MapKit class launch method.Launches a navigation app with a specified destination.
LaunchNavigator.navigate(destination, options);
LaunchNavigator.APP
constants. e.g. LaunchNavigator.APP.GOOGLE_MAPS
.LaunchNavigator.TRANSPORT_MODE
constants.LaunchNavigator.LAUNCH_MODE.MAPS
or LaunchNavigator.LAUNCH_MODE.TURN_BY_TURN
LaunchNavigator.LAUNCH_MODE.MAPS
if not specified.LaunchNavigator.LAUNCH_MODE.URI_SCHEME
or LaunchNavigator.LAUNCH_MODE.MAPKIT
LaunchNavigator.LAUNCH_MODE.URI_SCHEME
if not specified.{"t": "k"}
google_maps://?t=k&...
Determines if the given app is installed and available on the current device.
let app = LaunchNavigator.APP.WAZE;
LaunchNavigator.isAppAvailable(app)
.then((isAvailable) => {
console.log(LaunchNavigator.getAppDisplayName(app)+" is available: "+isAvailable);
})
.catch((error) => {
console.error(error);
});
LaunchNavigator.APP
.Returns a list indicating which apps are installed and available on the current device for the current platform.
LaunchNavigator.getAvailableApps()
.then((apps) => {
for(let app in apps){
console.log(LaunchNavigator.getAppDisplayName(app)+" is "+(apps[app] ? "available" : "unavailable"));
}
})
.catch((error) => {
console.error(error);
});
LaunchNavigator.APP
and the value is a boolean indicating whether the app is available.Returns the display name of the specified app.
let name = LaunchNavigator.getAppDisplayName(LaunchNavigator.APP.WAZE);
LaunchNavigator.APP
. e.g. LaunchNavigator.APP.GOOGLE_MAPS
.Returns list of supported apps on a given platform.
let apps = LaunchNavigator.getAppsForPlatform(platform);
LaunchNavigator.PLATFORM
. e.g. LaunchNavigator.PLATFORM.IOS
.LaunchNavigator.APP
constants.Indicates if an app on a given platform supports specification of transport mode.
let isSupported = LaunchNavigator.supportsTransportMode(app, platform, launchMode);
LaunchNavigator.APP
. e.g. LaunchNavigator.APP.GOOGLE_MAPS
.LaunchNavigator.PLATFORM
. e.g. LaunchNavigator.PLATFORM.IOS
.LaunchNavigator.LAUNCH_MODE
. e.g. LaunchNavigator.LAUNCH_MODE.MAPS
.Returns the list of transport modes supported by an app on a given platform.
let transportModes = LaunchNavigator.getTransportModes(app, platform, launchMode);
LaunchNavigator.APP
. e.g. LaunchNavigator.APP.GOOGLE_MAPS
.LaunchNavigator.PLATFORM
. e.g. LaunchNavigator.PLATFORM.IOS
.LaunchNavigator.LAUNCH_MODE
. e.g. LaunchNavigator.LAUNCH_MODE.MAPS
.LaunchNavigator.TRANSPORT_MODE
.
If app/platform(/launch mode) combination doesn't support specification of transport mode, the list will be empty;Indicates if an app on a given platform supports specification of a custom nickname for destination location.
let isSupported = LaunchNavigator.supportsDestName(app, platform, launchMode);
LaunchNavigator.APP
. e.g. LaunchNavigator.APP.GOOGLE_MAPS
.LaunchNavigator.PLATFORM
. e.g. LaunchNavigator.PLATFORM.IOS
.LaunchNavigator.LAUNCH_MODE
. e.g. LaunchNavigator.LAUNCH_MODE.MAPS
.Indicates if an app on a given platform supports specification of start location.
let isSupported = LaunchNavigator.supportsStart(app, platform, launchMode);
LaunchNavigator.APP
. e.g. LaunchNavigator.APP.GOOGLE_MAPS
.LaunchNavigator.PLATFORM
. e.g. LaunchNavigator.PLATFORM.IOS
.LaunchNavigator.LAUNCH_MODE
. e.g. LaunchNavigator.LAUNCH_MODE.MAPS
.Indicates if an app on a given platform supports specification of a custom nickname for start location.
let isSupported = LaunchNavigator.supportsStartName(app, platform, launchMode);
LaunchNavigator.APP
. e.g. LaunchNavigator.APP.GOOGLE_MAPS
.LaunchNavigator.PLATFORM
. e.g. LaunchNavigator.PLATFORM.IOS
.LaunchNavigator.LAUNCH_MODE
. e.g. LaunchNavigator.LAUNCH_MODE.MAPKIT
.Indicates if an app on a given platform supports specification of launch mode.
Currently only Google Maps on Android and Apple Maps on iOS supports this.
let isSupported = LaunchNavigator.supportsLaunchMode(app, platform);
LaunchNavigator.APP
. e.g. LaunchNavigator.APP.GOOGLE_MAPS
.LaunchNavigator.PLATFORM
. e.g. LaunchNavigator.PLATFORM.ANDROID
.Enables debug log output from the module to the JS and native consoles. By default debug is disabled.
LaunchNavigator.enableDebug(true);
Enables specification of the Google API key to use for accessing Google's Geocoding API. If you fail to set this on Android before attempting to use this module to launch a navigation app which requires a lat/lon coordinates as input, the module will raise an error if the input location is an address because it requires geocoding to a lat/lon coordinate. See Google API key for Android for more information.
Android only. Calling on iOS will have no effect.
LaunchNavigator.setGoogleApiKey("your_api_key");
The example project can be used to build and run a React Native app for Android & iOS:
https://github.com/dpa99c/react-native-launch-navigator-example
It demonstrates how this module can be used and validates its functionality.
setGoogleApiKey()
.geo:
URI schemeRunning on Android, in addition to discovering which explicitly supported apps are installed, the module will also detect which installed apps support using the geo:
URI scheme for use in navigation.
These are returned in the list of available apps.
By specifying the app
option as LaunchNavigator.APP.GEO
, the module will invoke a native Android chooser, to allow the user to select an app which supports the geo:
URI scheme for navigation.
Google Maps on Android can be launched using 3 launch modes by specifying the launchMode
option as a LaunchNavigator.LAUNCH_MODE
constant to navigate()
:
LaunchNavigator.LAUNCH_MODE.MAPS
) - launches in Map view. Enables start location to be specified, but not transport mode or destination name. Default if not specified.LaunchNavigator.LAUNCH_MODE.TURN_BY_TURN
) - launches in Navigation view. Enables transport mode to be specified, but not start location or destination name.LaunchNavigator.LAUNCH_MODE.GEO
) - invokes Navigation view via geo
: URI scheme. Enables destination name to be specified, but not start location or transport mode.LaunchNavigator.availableApps()
will always report it as present.LaunchNavigator.navigate()
Apple Maps app on iOS can be launched using 2 launch methods by specifying the launchMode
option as a LaunchNavigator.LAUNCH_MODE
constant to navigate()
:
LaunchNavigator.LAUNCH_MODE.URI_SCHEME
: use the URI scheme launch method. Default if not specified.LaunchNavigator.LAUNCH_MODE.MAPKIT
: use the MapKit class launch method.On both Android and iOS, the "ride type" will default to "Lyft" unless otherwise specified in the extras
list as id
.
See the Lyft documentation for URL scheme details and other supported ride types.
On both Android and iOS, the extra parameters client_id
and deep_link_product_id
are required by 99 Taxi
client_id
should follow the pattern MAP_***
where ***
is the client name given by the 99 Team.
client_id=MAP_123
deep_link_product_id
identifies the ride category
316
- POP ride326
- TOP ride327
- Taxis ridedeep_link_product_id=316
On Android, 99 Taxi is currently the only app where options.start
is a required parameter when calling navigate()
navigate()
is called without a start location and the selected app is 99 Taxi, the error callback will be invoked and the 99 Taxi app will not be launchedAndroidManifest.xml
Before reporting issues with this module, please first do the following:
When reporting issues, please give the following information:
A clear description of the problem
OS version(s) and device (or emulator) model(s) on which the problem was observed
Code example of calling the module which results in the observed issue
Example parameters (locations or place names) which results in the observed issue
Issues which fail to give a clear description of the problem as described above will be closed immediately
The MIT License
Copyright (c) 2018 Dave Alden (Working Edge Ltd.)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.