forked from dpa99c/react-native-launch-navigator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
218 lines (190 loc) · 9.46 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// Type definitions for react-native-launch-navigator
// Project: https://github.com/dpa99c/react-native-launch-navigator
// Definitions by: Dave Alden <https://github.com/dpa99c>
// Usage: import { LaunchNavigator, LaunchNavigatorOptions } from 'react-native-launch-navigator';
export interface LaunchNavigatorOptions {
/**
* name of the navigation app to use for directions.
* Specify using LaunchNavigator.APP constants.
* e.g. `LaunchNavigator.APP.GOOGLE_MAPS`.
*/
app?: string;
/**
* nickname to display in app for destination. e.g. "Bob's House".
*/
destinationName?: string;
/**
* Start point of the navigation.
* If not specified, the current device location will be used.
* Either:
* - a {string} containing the address. e.g. "Buckingham Palace, London"
* - a {string} containing a latitude/longitude coordinate. e.g. "50.1. -4.0"
* - an {array}, where the first element is the latitude and the second element is a longitude, as decimal numbers. e.g. [50.1, -4.0]
*/
start?: string | number[];
/**
* nickname to display in app for start . e.g. "My House".
*/
startName?: string;
/**
* Transportation mode for navigation: "driving", "walking" or "transit". Defaults to "driving" if not specified.
*/
transportMode?: string;
/**
* Android: mode in which to open Google Maps app.
* `LaunchNavigator.LAUNCH_MODE.MAPS` or `LaunchNavigator.LAUNCH_MODE.TURN_BY_TURN`
* Defaults to `LaunchNavigator.LAUNCH_MODE.MAPS` if not specified.
*
* iOS: method to use to open Apple Maps app.
* `LaunchNavigator.LAUNCH_MODE.URI_SCHEME` or `LaunchNavigator.LAUNCH_MODE.MAPKIT`
* Defaults to `LaunchNavigator.LAUNCH_MODE.URI_SCHEME` if not specified.
*/
launchMode?: string;
/**
* 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: `{"t": "k"}`
*/
extras?: any;
/**
* 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.
*/
enableGeocoding?: boolean;
}
export interface LaunchNavigator {
/**
* Supported platforms
*/
PLATFORM: any;
/**
* string constants, used to identify apps in native code
*/
APP: any;
/**
* All possible transport modes
*/
TRANSPORT_MODE: any;
/**
* Launch modes supported by Google Maps on Android
*/
LAUNCH_MODE: any;
/**
* Launches navigator app
* @param destination {string|number[]} Location name or coordinates (as string or array)
* Either:
* - a {string} containing the address. e.g. "Buckingham Palace, London"
* - a {string} containing a latitude/longitude coordinate. e.g. "50.1. -4.0"
* - an {array}, where the first element is the latitude and the second element is a longitude, as decimal numbers. e.g. [50.1, -4.0]
* @param options {LaunchNavigatorOptions}
* @return Promise
* - resolved when the navigation app is successfully launched
* - rejected if an error is encountered while launching the app. Will be passed a single string argument containing the error message.
*/
navigate: (
destination: string | number[],
options?: LaunchNavigatorOptions
) => Promise;
logEvent: (name: string, params?: any, valueToSum?: number) => void;
/**
* Determines if the given app is installed and available on the current device.
* @param app {string} appName - name of the app to check availability for. Define as a constant using `LaunchNavigator.APP`.
* @return {boolean} - indicates the availability of the specified app.
*/
isAppAvailable: (
app: string
) => boolean;
/**
* Returns a list indicating which apps are installed and available on the current device.
* @return {object} - a key/value object where the key is the app name as a constant in `LaunchNavigator.APP` and the value is a boolean indicating whether the app is available.
*/
getAvailableApps: () => object;
/**
* Returns the display name of the specified app.
* @param {string} app - specified as a constant in `LaunchNavigator.APP`. e.g. `LaunchNavigator.APP.GOOGLE_MAPS`.
* @return {string} - app display name. e.g. "Google Maps".
*/
getAppDisplayName: (app: string) => string;
/**
* Returns list of supported apps on a given platform.
* @param {string} platform - specified as a constant in `LaunchNavigator.PLATFORM`. e.g. `LaunchNavigator.PLATFORM.IOS`.
* @return {array} - apps supported on specified platform as a list of `LaunchNavigator.APP` constants.
*/
getAppsForPlatform: (platform: string) => string[];
/**
* Indicates if an app on a given platform supports specification of transport mode.
* @param {string} app - specified as a constant in `LaunchNavigator.APP`. e.g. `LaunchNavigator.APP.GOOGLE_MAPS`.
* @param {string} platform - specified as a constant in `LaunchNavigator.PLATFORM`. e.g. `LaunchNavigator.PLATFORM.IOS`.
* @param {string} launchMode - (optional) Only applies to Google Maps on Android. Specified as a constant in `LaunchNavigator.LAUNCH_MODE`. e.g. `LaunchNavigator.LAUNCH_MODE.MAPS`.
* @return {boolean} - true if app/platform combination supports specification of transport mode.
*/
supportsTransportMode: (
app: string,
platform: string,
launchMode?: string
) => boolean;
/**
* Returns the list of transport modes supported by an app on a given platform.
* @param {string} app - specified as a constant in `LaunchNavigator.APP`. e.g. `LaunchNavigator.APP.GOOGLE_MAPS`.
* @param {string} platform - specified as a constant in `LaunchNavigator.PLATFORM`. e.g. `LaunchNavigator.PLATFORM.IOS`.
* @param {string} launchMode - (optional) Only applies to Google Maps on Android. Specified as a constant in `LaunchNavigator.LAUNCH_MODE`. e.g. `LaunchNavigator.LAUNCH_MODE.MAPS`.
* @return {array} - list of transports modes as constants in `LaunchNavigator.TRANSPORT_MODE`.
* If app/platform combination doesn't support specification of transport mode, the list will be empty;
*/
getTransportModes: (
app: string,
platform: string,
launchMode?: string
) => string[];
/**
* Indicates if an app on a given platform supports specification of launch mode.
* Note that currently only Google Maps on Android does.
* @param {string} app - specified as a constant in `LaunchNavigator.APP`. e.g. `LaunchNavigator.APP.GOOGLE_MAPS`.
* @param {string} platform - specified as a constant in `LaunchNavigator.PLATFORM`. e.g. `LaunchNavigator.PLATFORM.ANDROID`.
* @return {boolean} - true if app/platform combination supports specification of transport mode.
*/
supportsLaunchMode: (
app: string,
platform: string
) => boolean;
/**
* Indicates if an app on a given platform supports specification of start location.
* @param {string} app - specified as a constant in `LaunchNavigator.APP`. e.g. `LaunchNavigator.APP.GOOGLE_MAPS`.
* @param {string} platform - specified as a constant in `LaunchNavigator.PLATFORM`. e.g. `LaunchNavigator.PLATFORM.IOS`.
* @param {string} launchMode - (optional) Only applies to Google Maps on Android. Specified as a constant in `LaunchNavigator.LAUNCH_MODE`. e.g. `LaunchNavigator.LAUNCH_MODE.MAPS`.
* @return {boolean} - true if app/platform combination supports specification of start location.
*/
supportsStart: (
app: string,
platform: string,
launchMode?: string
) => boolean;
/**
* Indicates if an app on a given platform supports specification of a custom nickname for start location.
* @param {string} app - specified as a constant in `LaunchNavigator.APP`. e.g. `LaunchNavigator.APP.GOOGLE_MAPS`.
* @param {string} platform - specified as a constant in `LaunchNavigator.PLATFORM`. e.g. `LaunchNavigator.PLATFORM.IOS`.
* @param {string} launchMode - (optional) Only applies to Apple Maps on iOS. Specified as a constant in `LaunchNavigator.LAUNCH_MODE`. e.g. `LaunchNavigator.LAUNCH_MODE.MAPKIT`.
* @return {boolean} - true if app/platform combination supports specification of start location.
*/
supportsStartName: (
app: string,
platform: string,
launchMode?: string
) => boolean;
/**
* Indicates if an app on a given platform supports specification of a custom nickname for destination location.
* @param {string} app - specified as a constant in `LaunchNavigator.APP`. e.g. `LaunchNavigator.APP.GOOGLE_MAPS`.
* @param {string} platform - specified as a constant in `LaunchNavigator.PLATFORM`. e.g. `LaunchNavigator.PLATFORM.IOS`.
* @param {string} launchMode - (optional) Applies to Google Maps on Android and Apple Maps on iOS. Specified as a constant in `LaunchNavigator.LAUNCH_MODE`. e.g. `LaunchNavigator.LAUNCH_MODE.MAPS`.
* @return {boolean} - true if app/platform combination supports specification of destination location.
*/
supportsDestName: (
app: string,
platform: string,
launchMode?: string
) => boolean;
/**
* Enables debug log output from the plugin to the JS and native consoles. By default debug is disabled.
* @param enabled {boolean}
*/
enableDebug: (
enabled: boolean
) => void;
}