Launch Navigator
Requires Cordova plugin: uk.co.workingedge.phonegap.plugin.launchnavigator. For more info, please see the LaunchNavigator plugin docs.
Repo: https://github.com/dpa99c/phonegap-launch-navigator
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator $ npm install --save @ionic-native/launch-navigator@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
- Windows
- Windows Phone 8
Usage
Please refer to the plugin's repo for detailed usage. This docs page only explains the Native wrapper.
import { LaunchNavigator, LaunchNavigatorOptions } from '@ionic-native/launch-navigator';
constructor(private launchNavigator: LaunchNavigator) { }
...
let options: LaunchNavigatorOptions = {
start: 'London, ON',
app: LaunchNavigator.APPS.UBER
};
this.launchNavigator.navigate('Toronto, ON', options)
.then(
success => console.log('Launched navigator'),
error => console.log('Error launching navigator', error)
);
Instance Members
APP
TRANSPORT_MODE
navigate(destination, options)
Launches navigator app
Param | Type | Details |
---|---|---|
destination |
string |Array.<number>
|
Location name or coordinates (as string or array) |
options |
LaunchNavigatorOptions
|
Returns: Promise<any>
isAppAvailable(app)
Determines if the given app is installed and available on the current device.
Param | Type | Details |
---|---|---|
app |
string
|
Returns: Promise<any>
availableApps()
Returns a list indicating which apps are installed and available on the current device.
Returns: Promise<string[]>
getAppDisplayName(app)
Returns the display name of the specified app.
Param | Type | Details |
---|---|---|
app |
string
|
Returns: string
getAppsForPlatform(platform)
Returns list of supported apps on a given platform.
Param | Type | Details |
---|---|---|
platform |
string
|
Returns: string[]
supportsTransportMode(app, platform)
Indicates if an app on a given platform supports specification of transport mode.
Param | Type | Details |
---|---|---|
app |
string
|
specified as a string, you can use one of the constants, e.g |
platform |
string
|
Returns: boolean
getTransportModes(app, platform)
Returns the list of transport modes supported by an app on a given platform.
Param | Type | Details |
---|---|---|
app |
string
|
|
platform |
string
|
Returns: string[]
supportsDestName(app, platform)
Param | Type | Details |
---|---|---|
app |
string
|
|
platform |
string
|
Returns: boolean
supportsStart(app, platform)
Indicates if an app on a given platform supports specification of start location.
Param | Type | Details |
---|---|---|
app |
string
|
|
platform |
string
|
Returns: boolean
supportsStartName(app, platform)
Param | Type | Details |
---|---|---|
app |
string
|
|
platform |
string
|
Returns: boolean
supportsLaunchMode(app, platform)
Indicates if an app on a given platform supports specification of launch mode. Note that currently only Google Maps on Android does.
Param | Type | Details |
---|---|---|
app |
string
|
|
platform |
string
|
Returns: boolean
userSelect(destination, options)
Param | Type | Details |
---|---|---|
destination |
string |Array.<number>
|
|
options |
LaunchNavigatorOptions
|
appSelection
LaunchNavigatorOptions
Param | Type | Details |
---|---|---|
successCallback |
Function
|
A callback to invoke when the navigation app is successfully launched. (optional) |
errorCallback |
(error: string) => void
|
A callback to invoke if an error is encountered while launching the app. A single string argument containing the error message will be passed in. (optional) |
app |
string
|
name of the navigation app to use for directions.
Specify using launchnavigator.APP constants.
e.g. |
destinationName |
string
|
nickname to display in app for destination. e.g. "Bob's House". (optional) |
start |
string | number[]
|
Start point of the navigation. If not specified, the current device location will be used. Either:
|
startName |
string
|
nickname to display in app for start . e.g. "My House". (optional) |
transportMode |
string
|
Transportation mode for navigation: "driving", "walking" or "transit". Defaults to "driving" if not specified. (optional) |
enableDebug |
boolean
|
If true, debug log output will be generated by the plugin. Defaults to false. (optional) |
extras |
any
|
a key/value map of extra app-specific parameters. For example, to tell Google Maps on Android to display Satellite view in "maps" launch mode: |
launchModeGoogleMaps |
string
|
(Android only) mode in which to open Google Maps app.
|
launchModeAppleMaps |
string
|
(iOS only) method to use to open Apple Maps app.
|
enableGeolocation |
boolean
|
If true, and input location type(s) doesn't match those required by the app, use geocoding to obtain the address/coords as required. Defaults to true. (optional) |
appSelection |
AppSelectionOptions
|
options related to the default native actionsheet picker which enables user to select which navigation app to launch if |
PromptsOptions
Param | Type | Details |
---|---|---|
callback |
(rememberChoice: boolean) => void
|
a function to pass the user's decision whether to remember their choice of app. This will be passed a single boolean value indicating the user's decision. (optional) |
headerText |
string
|
text to display in the native prompt header asking user whether to remember their choice. Defaults to "Remember your choice?" if not specified. (optional) |
bodyText |
string
|
text to display in the native prompt body asking user whether to remember their choice. Defaults to "Use the same app for navigating next time?" if not specified. (optional) |
yesButtonText |
string
|
text to display for the Yes button. Defaults to "Yes" if not specified. (optional) |
noButtonText |
string
|
text to display for the No button. Defaults to "No" if not specified. (optional) |
RememberChoiceOptions
Param | Type | Details |
---|---|---|
enabled |
boolean | string
|
whether to remember user choice of app for next time, instead of asking again for user choice.
|
promptFn |
(callback: (rememberChoice: boolean) => void) => void
|
a function which asks the user whether to remember their choice of app. If this is defined, then the default dialog prompt will not be shown, allowing for a custom UI for asking the user. This will be passed a callback function which should be invoked with a single boolean argument which indicates the user's decision to remember their choice. (optional) |
prompt |
PromptsOptions
|
options related to the default dialog prompt used to ask the user whether to remember their choice of app. (optional) |
AppSelectionOptions
Param | Type | Details |
---|---|---|
dialogHeaderText |
string
|
text to display in the native picker which enables user to select which navigation app to launch. Defaults to "Select app for navigation" if not specified. (optional) |
cancelButtonText |
string
|
text to display for the cancel button in the native picker which enables user to select which navigation app to launch. Defaults to "Cancel" if not specified. (optional) |
list |
string[]
|
List of apps, defined as |
callback |
(app: string) => void
|
Callback to invoke when the user selects an app in the native picker.
A single string argument is passed which is the app what was selected defined as a |
androidTheme |
number
|
(Android only) native picker theme. Specify using |
rememberChoice |
RememberChoiceOptions
|
options related to whether to remember user choice of app for next time, instead of asking again for user choice. (optional) |
UserChoice
Param | Type | Details |
---|---|---|
exists |
(callback: (exists: boolean) => void) => void
|
Indicates whether a user choice exists for a preferred navigator app. |
get |
(callback: (app: string) => void) => void
|
Returns current user choice of preferred navigator app. |
set |
(app: string, callback: () => void) => void
|
Sets the current user choice of preferred navigator app. |
clear |
(callback: () => void) => void
|
Clears the current user choice of preferred navigator app. |
UserPrompted
Param | Type | Details |
---|---|---|
get |
(callback: (exists: boolean) => void) => void
|
Indicates whether user has already been prompted whether to remember their choice a preferred navigator app. |
set |
(callback: () => void) => void
|
Sets flag indicating user has already been prompted whether to remember their choice a preferred navigator app. |
clear |
(callback: () => void) => void
|
Clears flag which indicates if user has already been prompted whether to remember their choice a preferred navigator app. |
AppSelection
Param | Type | Details |
---|---|---|
userChoice |
UserChoice
|
|
userPrompted |
UserPrompted
|