@transistorsoft/background-geolocation-types 5.0.0-beta.3 → 5.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/api/BackgroundGeolocation.d.ts +0 -1551
- package/dist/core/api/CurrentPositionRequest.d.ts +0 -36
- package/dist/core/api/DeviceSettings.d.ts +0 -63
- package/dist/core/api/Logger.d.ts +0 -400
- package/dist/core/api/State.d.ts +0 -63
- package/dist/core/api/TransistorAuthorizationService.d.ts +0 -110
- package/dist/core/config/ActivityConfig.d.ts +0 -260
- package/dist/core/config/AppConfig.d.ts +0 -581
- package/dist/core/config/AuthorizationConfig.d.ts +0 -191
- package/dist/core/config/Config.d.ts +0 -176
- package/dist/core/config/GeoConfig.d.ts +0 -876
- package/dist/core/config/HttpConfig.d.ts +0 -565
- package/dist/core/config/LocationFilter.d.ts +0 -256
- package/dist/core/config/LoggerConfig.d.ts +0 -313
- package/dist/core/config/NotificationConfig.d.ts +0 -504
- package/dist/core/config/PersistenceConfig.d.ts +0 -541
- package/dist/core/data/DeviceInfo.d.ts +0 -54
- package/dist/core/data/Geofence.d.ts +0 -5
- package/dist/core/data/Location.d.ts +0 -213
- package/dist/core/data/Sensors.d.ts +0 -22
- package/dist/core/events/AuthorizationEvent.d.ts +0 -9
- package/dist/core/events/ConnectivityChangeEvent.d.ts +0 -6
- package/dist/core/events/GeofenceEvent.d.ts +0 -10
- package/dist/core/events/GeofencesChangeEvent.d.ts +0 -7
- package/dist/core/events/HeadlessEvent.d.ts +0 -7
- package/dist/core/events/HeartbeatEvent.d.ts +0 -10
- package/dist/core/events/HttpEvent.d.ts +0 -8
- package/dist/core/events/MotionActivityEvent.d.ts +0 -7
- package/dist/core/events/MotionChangeEvent.d.ts +0 -7
- package/dist/core/events/ProviderChangeEvent.d.ts +0 -10
- package/dist/core/events/Subscription.d.ts +0 -83
- package/dist/docs-entry.js +0 -3
- package/dist/enums/AccuracyAuthorization.d.ts +0 -16
- package/dist/enums/AccuracyAuthorization.js +0 -12
- package/dist/enums/ActivityType.d.ts +0 -25
- package/dist/enums/ActivityType.js +0 -21
- package/dist/enums/AuthorizationStatus.d.ts +0 -16
- package/dist/enums/AuthorizationStatus.js +0 -13
- package/dist/enums/AuthorizationStrategy.d.ts +0 -9
- package/dist/enums/AuthorizationStrategy.js +0 -6
- package/dist/enums/DesiredAccuracy.d.ts +0 -6
- package/dist/enums/DesiredAccuracy.js +0 -5
- package/dist/enums/Event.d.ts +0 -9
- package/dist/enums/Event.js +0 -5
- package/dist/enums/GeofenceAction.d.ts +0 -17
- package/dist/enums/GeofenceAction.js +0 -13
- package/dist/enums/HttpMethod.d.ts +0 -7
- package/dist/enums/HttpMethod.js +0 -6
- package/dist/enums/KalmanProfile.d.ts +0 -26
- package/dist/enums/KalmanProfile.js +0 -25
- package/dist/enums/LocationError.d.ts +0 -19
- package/dist/enums/LocationError.js +0 -15
- package/dist/enums/LocationFilterPolicy.d.ts +0 -104
- package/dist/enums/LocationFilterPolicy.js +0 -103
- package/dist/enums/LocationRequest.d.ts +0 -19
- package/dist/enums/LocationRequest.js +0 -15
- package/dist/enums/LogLevel.d.ts +0 -20
- package/dist/enums/LogLevel.js +0 -16
- package/dist/enums/LogLevelName.d.ts +0 -6
- package/dist/enums/LogLevelName.js +0 -5
- package/dist/enums/MotionActivityType.d.ts +0 -6
- package/dist/enums/MotionActivityType.js +0 -5
- package/dist/enums/NotificationPriority.d.ts +0 -16
- package/dist/enums/NotificationPriority.js +0 -15
- package/dist/enums/PersistMode.d.ts +0 -7
- package/dist/enums/PersistMode.js +0 -6
- package/dist/enums/SQLQueryOrder.d.ts +0 -11
- package/dist/enums/SQLQueryOrder.js +0 -10
- package/dist/enums/TrackingMode.d.ts +0 -11
- package/dist/enums/TrackingMode.js +0 -10
- package/dist/enums/TriggerActivity.d.ts +0 -7
- package/dist/enums/TriggerActivity.js +0 -6
- package/dist/index.js +0 -4
- package/dist/legacy/LegacyConfig.d.ts +0 -19
- package/package.json +8 -9
|
@@ -1,599 +1,18 @@
|
|
|
1
1
|
import { NotificationConfig } from './NotificationConfig';
|
|
2
|
-
/**
|
|
3
|
-
* (__Android 11+__) Configure the dialog shown when requesting **Always** background
|
|
4
|
-
* location permission.
|
|
5
|
-
*
|
|
6
|
-
* Android 11 changed the location authorization flow and no longer presents an
|
|
7
|
-
* **“Allow all the time”** option on the initial system dialog.
|
|
8
|
-
* Instead, Android allows apps to show a custom rationale dialog explaining why
|
|
9
|
-
* background access is required.
|
|
10
|
-
*
|
|
11
|
-
* This dialog can take the user directly to the app’s **Location Permissions**
|
|
12
|
-
* settings screen, where they can explicitly grant **Allow all the time**.
|
|
13
|
-
* The SDK presents this dialog automatically when:
|
|
14
|
-
*
|
|
15
|
-
* - {@link GeoConfig.locationAuthorizationRequest} is `"Always"`, and
|
|
16
|
-
* - {@link AppConfig.backgroundPermissionRationale} is configured.
|
|
17
|
-
*
|
|
18
|
-
* 
|
|
19
|
-
*
|
|
20
|
-
* **Behavior Notes**
|
|
21
|
-
*
|
|
22
|
-
* - Android presents the {@link AppConfig.backgroundPermissionRationale} dialog **once only**.
|
|
23
|
-
* After the user presses the `positiveAction`, it will not be shown again
|
|
24
|
-
* (pressing *Cancel* does **not** count as acceptance).
|
|
25
|
-
* - If the user later resets your app’s Location permission to **Ask every time**,
|
|
26
|
-
* the rationale dialog becomes eligible to be shown again.
|
|
27
|
-
*
|
|
28
|
-
* 
|
|
29
|
-
* 
|
|
30
|
-
*
|
|
31
|
-
* __Example__
|
|
32
|
-
*
|
|
33
|
-
* ```ts
|
|
34
|
-
* import BackgroundGeolocation from "react-native-background-geolocation";
|
|
35
|
-
*
|
|
36
|
-
* BackgroundGeolocation.ready({
|
|
37
|
-
* geolocation: {
|
|
38
|
-
* locationAuthorizationRequest: 'Always'
|
|
39
|
-
* },
|
|
40
|
-
* app: {
|
|
41
|
-
* backgroundPermissionRationale: {
|
|
42
|
-
* title: "Allow {applicationName} to access this device's location in the background?",
|
|
43
|
-
* message: "To track your activity in the background, please enable {backgroundPermissionOptionLabel} location access.",
|
|
44
|
-
* positiveAction: "Change to {backgroundPermissionOptionLabel}",
|
|
45
|
-
* negativeAction: "Cancel"
|
|
46
|
-
* }
|
|
47
|
-
* }
|
|
48
|
-
* });
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* __Template Tags__
|
|
52
|
-
*
|
|
53
|
-
* The following template variables can be used inside any rationale field by writing
|
|
54
|
-
* them as `{tagName}`:
|
|
55
|
-
*
|
|
56
|
-
* | Template Tag | Default value | Description |
|
|
57
|
-
* |-----------------------------------------|----------------------|-------------|
|
|
58
|
-
* | **`{backgroundPermissionOptionLabel}`** | "Allow all the time" | (API 30+) Localized label for the background location permission option. |
|
|
59
|
-
* | **`{applicationName}`** | App name | Localized application name from `AndroidManifest`. |
|
|
60
|
-
*
|
|
61
|
-
* __See also__
|
|
62
|
-
* - {@link GeoConfig.locationAuthorizationRequest}
|
|
63
|
-
* - {@link BackgroundGeolocation.requestPermission}
|
|
64
|
-
* - [Android 11 Location Updates](https://developer.android.com/about/versions/11/privacy/location)
|
|
65
|
-
*
|
|
66
|
-
* @category Config
|
|
67
|
-
*/
|
|
68
2
|
export interface PermissionRationale {
|
|
69
|
-
/**
|
|
70
|
-
* Title for the Android background location permission dialog.
|
|
71
|
-
*/
|
|
72
3
|
title?: string;
|
|
73
|
-
/**
|
|
74
|
-
* The body text of the dialog.
|
|
75
|
-
* Provide an explanation of why you need this permission, similar in purpose to iOS' __`NSLocationAlwaysAndWhenInUseUsageDescription`__.
|
|
76
|
-
*/
|
|
77
4
|
message?: string;
|
|
78
|
-
/**
|
|
79
|
-
* The text to display on the *positive action* button.
|
|
80
|
-
*/
|
|
81
5
|
positiveAction?: string;
|
|
82
|
-
/**
|
|
83
|
-
* The text to display on the *negative action* button (eg: *Cancel*)
|
|
84
|
-
*/
|
|
85
6
|
negativeAction?: string;
|
|
86
7
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Application & lifecycle configuration.
|
|
89
|
-
*
|
|
90
|
-
* `AppConfig` groups options that control how the SDK integrates with your app’s
|
|
91
|
-
* lifecycle: start/stop behavior on terminate and reboot, headless/background
|
|
92
|
-
* behavior, periodic heartbeats, scheduler windows, foreground notifications, and
|
|
93
|
-
* the Android background-permission rationale dialog.
|
|
94
|
-
*
|
|
95
|
-
* Use this class via {@link Config.app}.
|
|
96
|
-
*
|
|
97
|
-
* ```ts
|
|
98
|
-
* BackgroundGeolocation.ready({
|
|
99
|
-
* app: {
|
|
100
|
-
* stopOnTerminate: false,
|
|
101
|
-
* startOnBoot: true
|
|
102
|
-
* }
|
|
103
|
-
* });
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
|
-
* __What belongs in `AppConfig`?__
|
|
107
|
-
*
|
|
108
|
-
* - Whether tracking **stops on app terminate**: see {@link AppConfig.stopOnTerminate}.
|
|
109
|
-
* - Whether tracking **starts after device reboot**: see {@link AppConfig.startOnBoot}.
|
|
110
|
-
* - Android **headless** mode: see {@link AppConfig.enableHeadless}.
|
|
111
|
-
* - Periodic **heartbeat** callback: see {@link AppConfig.heartbeatInterval}.
|
|
112
|
-
* - **Scheduler** windows for automated start/stop: see {@link AppConfig.schedule} and {@link AppConfig.scheduleUseAlarmManager}.
|
|
113
|
-
* - Foreground-service **notification** options (Android): see {@link AppConfig.notification}.
|
|
114
|
-
* - Background-permission **rationale** for Android 10+: see {@link AppConfig.backgroundPermissionRationale}.
|
|
115
|
-
* - iOS background **preventSuspend** flag for heartbeat support: see {@link AppConfig.preventSuspend}.
|
|
116
|
-
*
|
|
117
|
-
* __Platform notes__
|
|
118
|
-
*
|
|
119
|
-
* **iOS**
|
|
120
|
-
* - With {@link AppConfig.stopOnTerminate} set to `false`, the SDK creates a *stationary geofence* and iOS will relaunch
|
|
121
|
-
* your app in the background when the device exits that region.
|
|
122
|
-
* - {@link AppConfig.preventSuspend} is required for heartbeat events and consumes additional battery — use with caution.
|
|
123
|
-
*
|
|
124
|
-
* **Android**
|
|
125
|
-
* - With {@link AppConfig.enableHeadless} set to `true`, the native background-service continues working even after the
|
|
126
|
-
* JS/UI process is killed. Pair this with {@link HttpConfig.url} to ensure continuous uploads.
|
|
127
|
-
* - The **scheduler** uses Android’s `AlarmManager` by default; control this with {@link AppConfig.scheduleUseAlarmManager}.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
*
|
|
131
|
-
* Configure once at startup:
|
|
132
|
-
*
|
|
133
|
-
* ```ts
|
|
134
|
-
* import BackgroundGeolocation, {
|
|
135
|
-
* type Config,
|
|
136
|
-
* type AppConfig,
|
|
137
|
-
* PermissionRationale,
|
|
138
|
-
* Notification
|
|
139
|
-
* } from 'react-native-background-geolocation';
|
|
140
|
-
*
|
|
141
|
-
* const config: Config = {
|
|
142
|
-
* app: {
|
|
143
|
-
* stopOnTerminate: false,
|
|
144
|
-
* startOnBoot: true,
|
|
145
|
-
* enableHeadless: true,
|
|
146
|
-
* heartbeatInterval: 60,
|
|
147
|
-
* backgroundPermissionRationale: {
|
|
148
|
-
* title: "Allow MyApp to access this device's location even when closed.",
|
|
149
|
-
* message: "This app collects location data to record your trips and mileage.",
|
|
150
|
-
* positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
|
|
151
|
-
* negativeAction: 'Cancel'
|
|
152
|
-
* },
|
|
153
|
-
* notification: {
|
|
154
|
-
* title: 'Background Geolocation',
|
|
155
|
-
* text: 'Tracking location',
|
|
156
|
-
* smallIcon: 'mipmap/ic_launcher'
|
|
157
|
-
* },
|
|
158
|
-
* schedule: ['1-5 09:00-17:00'], // Weekdays 9–5
|
|
159
|
-
* scheduleUseAlarmManager: true
|
|
160
|
-
* }
|
|
161
|
-
* };
|
|
162
|
-
*
|
|
163
|
-
* await BackgroundGeolocation.ready(config);
|
|
164
|
-
* ```
|
|
165
|
-
*
|
|
166
|
-
* Update later at runtime:
|
|
167
|
-
*
|
|
168
|
-
* ```ts
|
|
169
|
-
* await BackgroundGeolocation.setConfig({
|
|
170
|
-
* app: {
|
|
171
|
-
* heartbeatInterval: 120 // slow down heartbeats
|
|
172
|
-
* }
|
|
173
|
-
* });
|
|
174
|
-
* ```
|
|
175
|
-
*
|
|
176
|
-
* __Migration from legacy `Config` properties__
|
|
177
|
-
*
|
|
178
|
-
* The following legacy properties are **deprecated** on {@link Config} and should now
|
|
179
|
-
* be supplied via `Config.app`:
|
|
180
|
-
*
|
|
181
|
-
* - `Config.stopOnTerminate`
|
|
182
|
-
* - `Config.startOnBoot`
|
|
183
|
-
* - `Config.enableHeadless`
|
|
184
|
-
* - `Config.heartbeatInterval`
|
|
185
|
-
* - `Config.schedule`
|
|
186
|
-
* - `Config.scheduleUseAlarmManager`
|
|
187
|
-
* - `Config.notification`
|
|
188
|
-
* - `Config.backgroundPermissionRationale`
|
|
189
|
-
* - `Config.preventSuspend`
|
|
190
|
-
*
|
|
191
|
-
* @category Config
|
|
192
|
-
*/
|
|
193
8
|
export interface AppConfig {
|
|
194
|
-
/**
|
|
195
|
-
* Controls whether to continue location-tracking after the application is **terminated**.
|
|
196
|
-
*
|
|
197
|
-
* Defaults to **`true`**.
|
|
198
|
-
* When the user terminates the app, the plugin will call {@link BackgroundGeolocation.stop | stop()},
|
|
199
|
-
* ending tracking.
|
|
200
|
-
* Set {@link AppConfig.stopOnTerminate} to **`false`** to continue tracking after the app is terminated.
|
|
201
|
-
*
|
|
202
|
-
* If you *do* configure **`stopOnTerminate: false`**, your application **will** terminate immediately when the user swipes it away.
|
|
203
|
-
* However, Android and iOS behave very differently *after* termination:
|
|
204
|
-
*
|
|
205
|
-
* __iOS__
|
|
206
|
-
*
|
|
207
|
-
* Before an iOS app terminates, the SDK creates a **stationary geofence** of
|
|
208
|
-
* {@link GeoConfig.stationaryRadius} meters around the last known position.
|
|
209
|
-
* When the user moves beyond this stationary geofence (typically ~200 meters), iOS will
|
|
210
|
-
* **fully relaunch your application in the background**, and tracking will automatically resume.
|
|
211
|
-
*
|
|
212
|
-
* This works even after device reboot because geofences are monitored entirely by iOS at the OS level.
|
|
213
|
-
*
|
|
214
|
-
* In the illustration below, imagine the user terminated the application at the **red circle** on the right.
|
|
215
|
-
* As soon as the device moves **~200 meters**, exiting the stationary geofence, iOS re-launches the app
|
|
216
|
-
* and the SDK resumes tracking.
|
|
217
|
-
*
|
|
218
|
-
* ℹ️ *Demo video:*
|
|
219
|
-
* https://www.youtube.com/watch?v=aR6r8qV1TI8&t=214s
|
|
220
|
-
*
|
|
221
|
-
* 
|
|
222
|
-
*
|
|
223
|
-
* __Android__
|
|
224
|
-
*
|
|
225
|
-
* Unlike iOS, Android does **not** pause tracking when the user terminates the app.
|
|
226
|
-
* The native background service continues running **headlessly**, even without the JS/UI process.
|
|
227
|
-
*
|
|
228
|
-
* If relying on headless mode, you must configure {@link HttpConfig.url} so that the background service
|
|
229
|
-
* can continue posting locations to your server.
|
|
230
|
-
*
|
|
231
|
-
* __See also__
|
|
232
|
-
* - {@link AppConfig.enableHeadless}
|
|
233
|
-
* - [Android Headless Mode](github:wiki/Android-Headless-Mode)
|
|
234
|
-
*/
|
|
235
9
|
stopOnTerminate?: boolean;
|
|
236
|
-
/**
|
|
237
|
-
* Controls whether to resume location-tracking after the device is **rebooted**.
|
|
238
|
-
*
|
|
239
|
-
* Defaults to **`false`**.
|
|
240
|
-
*
|
|
241
|
-
* Set {@link AppConfig.startOnBoot} to **`true`** to automatically re-engage background tracking
|
|
242
|
-
* after a device restart.
|
|
243
|
-
*
|
|
244
|
-
* __iOS__
|
|
245
|
-
*
|
|
246
|
-
* iOS cannot **immediately** begin tracking after a device reboot. Similar to {@link AppConfig.stopOnTerminate}: `false`, iOS will not relaunch your app until:
|
|
247
|
-
* - The device moves beyond the **stationary geofence** created around the last known location, or
|
|
248
|
-
* - A system **Background Fetch** event fires (typically every ~15 minutes), which can also restart your app.
|
|
249
|
-
*
|
|
250
|
-
* __Android__
|
|
251
|
-
*
|
|
252
|
-
* When {@link AppConfig.startOnBoot} is `true`, Android will automatically relaunch the SDK’s
|
|
253
|
-
* background service after reboot (and initial device unlock).
|
|
254
|
-
*
|
|
255
|
-
* If {@link AppConfig.enableHeadless} is also `true`, tracking will resume even if the JS/UI layer
|
|
256
|
-
* has not yet started.
|
|
257
|
-
*
|
|
258
|
-
* __See also__
|
|
259
|
-
* - {@link AppConfig.enableHeadless}
|
|
260
|
-
* - {@link AppConfig.stopOnTerminate}
|
|
261
|
-
*/
|
|
262
10
|
startOnBoot?: boolean;
|
|
263
|
-
/**
|
|
264
|
-
* __`[Android only]`__ Enables "Headless" operation allowing you to respond to events after you app has been terminated with [[stopOnTerminate]] __`false`__.
|
|
265
|
-
*
|
|
266
|
-
* Defaults to __`false`__. In this Android terminated state, where only the plugin's foreground-service remains running, you can respond to all the plugin's events with your own callback. For more information, see [[BackgroundGeolocation.registerHeadlessTask]].
|
|
267
|
-
*
|
|
268
|
-
* __ℹ️ Note:__
|
|
269
|
-
* - Requires {@link AppConfig.stopOnTerminate} __`false`__.
|
|
270
|
-
* - If you've configured {@link AppConfig.stopOnTerminate} __`false`__, {@link BackgroundGeolocation} will continue to record locations (and post them to your configured {@link HttpConfig.url}) *regardless of* __`enabledHeadless: true`__. You should enable this option *only if* you wish to perform some custom work during the headless state (for example, posting a local notification).
|
|
271
|
-
*
|
|
272
|
-
* +__ℹ️ See also:__
|
|
273
|
-
* - 📘 [Android Headless Mode](github:wiki/Android-Headless-Mode).
|
|
274
|
-
* - {@link BackgroundGeolocation.registerHeadlessTask}
|
|
275
|
-
*/
|
|
276
11
|
enableHeadless?: boolean;
|
|
277
|
-
/**
|
|
278
|
-
* Controls the rate (in seconds) at which {@link BackgroundGeolocation.onHeartbeat}
|
|
279
|
-
*
|
|
280
|
-
* events will fire.
|
|
281
|
-
*
|
|
282
|
-
* **⚠️ Warning**
|
|
283
|
-
*
|
|
284
|
-
* - On **iOS**, {@link BackgroundGeolocation.onHeartbeat} will fire **only** when {@link AppConfig.preventSuspend} is set to `true`.
|
|
285
|
-
* - On **Android**, the *minimum* interval is **60 seconds**.
|
|
286
|
-
* - It is **not possible** to configure a `heartbeatInterval` faster than 60 seconds.
|
|
287
|
-
*
|
|
288
|
-
* @example
|
|
289
|
-
*
|
|
290
|
-
* ```ts
|
|
291
|
-
* BackgroundGeolocation.ready({
|
|
292
|
-
* app: {
|
|
293
|
-
* preventSuspend: true,
|
|
294
|
-
* heartbeatInterval: 60
|
|
295
|
-
* }
|
|
296
|
-
* });
|
|
297
|
-
*
|
|
298
|
-
* BackgroundGeolocation.onHeartbeat((event) => {
|
|
299
|
-
* console.log("[onHeartbeat]", event);
|
|
300
|
-
*
|
|
301
|
-
* // Optionally request a new location during heartbeat.
|
|
302
|
-
* BackgroundGeolocation.getCurrentPosition({
|
|
303
|
-
* samples: 1,
|
|
304
|
-
* persist: true
|
|
305
|
-
* }).then((location) => {
|
|
306
|
-
* console.log("[getCurrentPosition]", location);
|
|
307
|
-
* });
|
|
308
|
-
* });
|
|
309
|
-
* ```
|
|
310
|
-
*
|
|
311
|
-
* **ℹ️ See also**
|
|
312
|
-
* - {@link BackgroundGeolocation.onHeartbeat}
|
|
313
|
-
*/
|
|
314
12
|
heartbeatInterval?: number;
|
|
315
|
-
/**
|
|
316
|
-
* Configures a cron-like automated schedule telling the SDK when to
|
|
317
|
-
* {@link BackgroundGeolocation.start | start} and
|
|
318
|
-
* {@link BackgroundGeolocation.stop | stop} tracking.
|
|
319
|
-
*
|
|
320
|
-
* @example
|
|
321
|
-
* ```ts
|
|
322
|
-
* "{DAY(s)} {START_TIME}-{END_TIME}"
|
|
323
|
-
* ```
|
|
324
|
-
*
|
|
325
|
-
* - Times are in **24h format**.
|
|
326
|
-
* - `DAY` uses **Locale.US** numbering: **Sunday = 1**, **Saturday = 7**.
|
|
327
|
-
* - You may provide:
|
|
328
|
-
* - a single day: `"1"`
|
|
329
|
-
* - a comma-separated list: `"2,4,6"`
|
|
330
|
-
* - a range: `"2-6"`
|
|
331
|
-
*
|
|
332
|
-
* @example
|
|
333
|
-
* ```ts
|
|
334
|
-
* BackgroundGeolocation.ready({
|
|
335
|
-
* app: {
|
|
336
|
-
* schedule: [
|
|
337
|
-
* "1 17:30-21:00", // Sunday: 5:30pm–9pm
|
|
338
|
-
* "2-6 09:00-17:00", // Mon–Fri: 9am–5pm
|
|
339
|
-
* "2,4,6 20:00-00:00", // Mon, Wed, Fri: 8pm–midnight
|
|
340
|
-
* "7 10:00-19:00" // Saturday: 10am–7pm
|
|
341
|
-
* ]
|
|
342
|
-
* }
|
|
343
|
-
* }).then((state) => {
|
|
344
|
-
* // Start the Scheduler
|
|
345
|
-
* BackgroundGeolocation.startSchedule();
|
|
346
|
-
* });
|
|
347
|
-
*
|
|
348
|
-
* // Listen for schedule state changes
|
|
349
|
-
* BackgroundGeolocation.onSchedule((state) => {
|
|
350
|
-
* console.log("[onSchedule] enabled?", state.enabled);
|
|
351
|
-
* });
|
|
352
|
-
*
|
|
353
|
-
* // Later (e.g., user logout)
|
|
354
|
-
* BackgroundGeolocation.stopSchedule();
|
|
355
|
-
* BackgroundGeolocation.stop(); // if tracking is currently enabled
|
|
356
|
-
*
|
|
357
|
-
* // Modify schedule using setConfig
|
|
358
|
-
* BackgroundGeolocation.setConfig({
|
|
359
|
-
* app: {
|
|
360
|
-
* schedule: [
|
|
361
|
-
* "1-7 09:00-10:00",
|
|
362
|
-
* "1-7 11:00-12:00",
|
|
363
|
-
* "1-7 13:00-14:00",
|
|
364
|
-
* "1-7 15:00-16:00",
|
|
365
|
-
* "1-7 17:00-18:00",
|
|
366
|
-
* "2,4,6 19:00-22:00"
|
|
367
|
-
* ]
|
|
368
|
-
* }
|
|
369
|
-
* });
|
|
370
|
-
* ```
|
|
371
|
-
*
|
|
372
|
-
* **Literal Dates**
|
|
373
|
-
*
|
|
374
|
-
* The schedule may use literal date ranges.
|
|
375
|
-
*
|
|
376
|
-
* ```txt
|
|
377
|
-
* "yyyy-mm-dd HH:mm-HH:mm"
|
|
378
|
-
* ```
|
|
379
|
-
*
|
|
380
|
-
* @example
|
|
381
|
-
* ```ts
|
|
382
|
-
* BackgroundGeolocation.ready({
|
|
383
|
-
* app: {
|
|
384
|
-
* schedule: [
|
|
385
|
-
* "2018-01-01 09:00-17:00"
|
|
386
|
-
* ]
|
|
387
|
-
* }
|
|
388
|
-
* });
|
|
389
|
-
* ```
|
|
390
|
-
*
|
|
391
|
-
* Or specify distinct start **and** stop dates:
|
|
392
|
-
*
|
|
393
|
-
* ```txt
|
|
394
|
-
* "yyyy-mm-dd-HH:mm yyyy-mm-dd-HH:mm"
|
|
395
|
-
* ```
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* ```ts
|
|
399
|
-
* BackgroundGeolocation.ready({
|
|
400
|
-
* app: {
|
|
401
|
-
* schedule: [
|
|
402
|
-
* "2018-01-01-09:00 2019-01-01-17:00" // track for 1 year
|
|
403
|
-
* ]
|
|
404
|
-
* }
|
|
405
|
-
* });
|
|
406
|
-
* ```
|
|
407
|
-
*
|
|
408
|
-
* **Scheduling Geofences-Only vs Location + Geofences**
|
|
409
|
-
*
|
|
410
|
-
* Append `geofence` or `location` to explicitly choose a tracking mode:
|
|
411
|
-
*
|
|
412
|
-
* ```ts
|
|
413
|
-
* BackgroundGeolocation.ready({
|
|
414
|
-
* app: {
|
|
415
|
-
* schedule: [
|
|
416
|
-
* "1-7 09:00-17:00 location",
|
|
417
|
-
* "1-7 18:00-12:00 geofence"
|
|
418
|
-
* ]
|
|
419
|
-
* }
|
|
420
|
-
* ```
|
|
421
|
-
*
|
|
422
|
-
* Since `location` is the default mode, it may be omitted:
|
|
423
|
-
*
|
|
424
|
-
* ```ts
|
|
425
|
-
* BackgroundGeolocation.ready({
|
|
426
|
-
* app: {
|
|
427
|
-
* schedule: [
|
|
428
|
-
* "1-7 09:00-17:00 location",
|
|
429
|
-
* "1-7 18:00-12:00 geofence"
|
|
430
|
-
* ]
|
|
431
|
-
* }
|
|
432
|
-
* });
|
|
433
|
-
* ```
|
|
434
|
-
*
|
|
435
|
-
* Since `location` is the default mode, it may be omitted:
|
|
436
|
-
* `"1-7 13:00-14:00 geofence"`
|
|
437
|
-
*
|
|
438
|
-
* **iOS**
|
|
439
|
-
*
|
|
440
|
-
* - iOS **cannot** evaluate the schedule *exactly* at the configured time.
|
|
441
|
-
* Evaluation occurs only when the app is awakened.
|
|
442
|
-
* - When in a scheduled **off** period, iOS continues monitoring low-power
|
|
443
|
-
* **Significant Location Changes (SLC)**.
|
|
444
|
-
* This guarantees periodic evaluation, especially when
|
|
445
|
-
* `{@link AppConfig.stopOnTerminate}` is `false` and the OS halts
|
|
446
|
-
* traditional Background Fetch.
|
|
447
|
-
* - Schedule evaluation occurs when:
|
|
448
|
-
* - the app pauses/resumes,
|
|
449
|
-
* - any location is recorded (including SLC),
|
|
450
|
-
* - a Background Fetch event fires.
|
|
451
|
-
*
|
|
452
|
-
* **Android**
|
|
453
|
-
*
|
|
454
|
-
* - Uses `AlarmManager.setExactAndAllowWhileIdle`, typically evaluating
|
|
455
|
-
* on-the-minute.
|
|
456
|
-
*
|
|
457
|
-
* **ℹ️ See also**
|
|
458
|
-
* - {@link BackgroundGeolocation.startSchedule}
|
|
459
|
-
* - {@link BackgroundGeolocation.stopSchedule}
|
|
460
|
-
*/
|
|
461
13
|
schedule?: string[];
|
|
462
|
-
/**
|
|
463
|
-
* __Android only__ Force the Android scheduler to use `AlarmManager` (more precise) instead of `JobScheduler`. Defaults to `false`.
|
|
464
|
-
*
|
|
465
|
-
* ```ts
|
|
466
|
-
* BackgroundGeolocation.ready({
|
|
467
|
-
* app: {
|
|
468
|
-
* schedule: ["1-7 09:00-17:00"],
|
|
469
|
-
* scheduleUseAlarmManager: true
|
|
470
|
-
* }
|
|
471
|
-
* });
|
|
472
|
-
* ```
|
|
473
|
-
*/
|
|
474
14
|
scheduleUseAlarmManager?: boolean;
|
|
475
|
-
/**
|
|
476
|
-
* [__Android only]__ Configures the persistent foreground-service [[Notification]] required by Android.
|
|
477
|
-
*
|
|
478
|
-
* 
|
|
479
|
-
*
|
|
480
|
-
* See {@link NotificationConfig} for detailed usage.
|
|
481
|
-
*
|
|
482
|
-
* @example
|
|
483
|
-
* ```typescript
|
|
484
|
-
* BackgroundGeolocation.ready({
|
|
485
|
-
* app: {
|
|
486
|
-
* notification: {
|
|
487
|
-
* title: "Background tracking engaged",
|
|
488
|
-
* text: "My notification text"
|
|
489
|
-
* }
|
|
490
|
-
* }
|
|
491
|
-
* });
|
|
492
|
-
* ```
|
|
493
|
-
*/
|
|
494
15
|
notification?: NotificationConfig;
|
|
495
|
-
/**
|
|
496
|
-
* (__Android 11+__) Configures the dialog shown when requesting *Always* location
|
|
497
|
-
* permission on Android 11+.
|
|
498
|
-
*
|
|
499
|
-
* Android 11 changed location authorization behavior and removed the
|
|
500
|
-
* **“Allow all the time”** button from the system permission dialog.
|
|
501
|
-
* Instead, apps may present a custom rationale dialog explaining *why* background
|
|
502
|
-
* access is required. Selecting the dialog’s `positiveAction` sends the user
|
|
503
|
-
* directly to the system **Location Permissions** screen, where they must
|
|
504
|
-
* explicitly enable **Allow all the time**.
|
|
505
|
-
*
|
|
506
|
-
* This SDK shows that dialog automatically when you have supplied
|
|
507
|
-
* {@link AppConfig.backgroundPermissionRationale}.
|
|
508
|
-
*
|
|
509
|
-
* 
|
|
510
|
-
*
|
|
511
|
-
* - Android will show the rationale dialog **only once**. After the user presses
|
|
512
|
-
* the `positiveAction`, it will not appear again.
|
|
513
|
-
* (Pressing **Cancel** does *not* count.)
|
|
514
|
-
* - If the user later resets your app’s Location Permission to **Ask every time**,
|
|
515
|
-
* the rationale dialog *may* be presented again.
|
|
516
|
-
*
|
|
517
|
-
* 
|
|
518
|
-
* 
|
|
519
|
-
*
|
|
520
|
-
* @example
|
|
521
|
-
* ```ts
|
|
522
|
-
* BackgroundGeolocation.ready({
|
|
523
|
-
* geolocation: {
|
|
524
|
-
* locationAuthorizationRequest: 'Always'
|
|
525
|
-
* },
|
|
526
|
-
* app: {
|
|
527
|
-
* backgroundPermissionRationale: {
|
|
528
|
-
* title: "Allow {applicationName} to access this device's location in the background?",
|
|
529
|
-
* message: "To track your activity in the background, please enable {backgroundPermissionOptionLabel} location permission.",
|
|
530
|
-
* positiveAction: "Change to {backgroundPermissionOptionLabel}",
|
|
531
|
-
* negativeAction: "Cancel"
|
|
532
|
-
* }
|
|
533
|
-
* }
|
|
534
|
-
* });
|
|
535
|
-
* ```
|
|
536
|
-
*
|
|
537
|
-
* __Template Tags__
|
|
538
|
-
*
|
|
539
|
-
* You may embed the following template variables inside {@link PermissionRationale | PermissionRationale} fields, wrapped as **`{tagName}`**:
|
|
540
|
-
*
|
|
541
|
-
* | Template Tag | Default value | Description |
|
|
542
|
-
* |-----------------------------------------|----------------------|-------------|
|
|
543
|
-
* | **`{backgroundPermissionOptionLabel}`** | *Allow all the time* | To track your activity in the background, please enable {backgroundPermissionOptionLabel} location permission. |
|
|
544
|
-
* | **`{applicationName}`** | Your app name | From `AndroidManifest.xml` |
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
* **See also**
|
|
549
|
-
* - {@link GeoConfig.locationAuthorizationRequest}
|
|
550
|
-
* - {@link BackgroundGeolocation.requestPermission}
|
|
551
|
-
* - [Location updates in Android 11](https://developer.android.com/about/versions/11/privacy/location)
|
|
552
|
-
*/
|
|
553
16
|
backgroundPermissionRationale?: PermissionRationale;
|
|
554
|
-
/**
|
|
555
|
-
* **iOS only** — Prevent iOS from suspending your application after location-services
|
|
556
|
-
* have been turned off while running in the background.
|
|
557
|
-
*
|
|
558
|
-
* Defaults to **`false`**.
|
|
559
|
-
*
|
|
560
|
-
* Set **`true`** to keep your application alive in the background even after iOS
|
|
561
|
-
* disables location-services. This is required when using a
|
|
562
|
-
* {@link AppConfig.heartbeatInterval | heartbeat interval}.
|
|
563
|
-
*
|
|
564
|
-
* **⚠️ Warning**
|
|
565
|
-
*
|
|
566
|
-
* - `preventSuspend: true` should be used **only for very specific use-cases**.
|
|
567
|
-
* It has a **large and noticeable impact on battery consumption**.
|
|
568
|
-
* - You should enable `preventSuspend` only for controlled periods of time.
|
|
569
|
-
* It is **not suitable** for continuous 24/7 operation.
|
|
570
|
-
* - When the device is **unplugged** with the screen **off**, iOS still throttles
|
|
571
|
-
* {@link BackgroundGeolocation.onHeartbeat} about **2 minutes** after entering the
|
|
572
|
-
* background.
|
|
573
|
-
*
|
|
574
|
-
* Heartbeats resume immediately if:
|
|
575
|
-
* - the screen turns on, or
|
|
576
|
-
* - even the slightest device-motion is detected.
|
|
577
|
-
*
|
|
578
|
-
* @example
|
|
579
|
-
* ```ts
|
|
580
|
-
* // Subscribe to heartbeat events
|
|
581
|
-
* BackgroundGeolocation.onHeartbeat((event) => {
|
|
582
|
-
* console.log("[onHeartbeat]", event);
|
|
583
|
-
* });
|
|
584
|
-
*
|
|
585
|
-
* // Enable preventSuspend via AppConfig
|
|
586
|
-
* BackgroundGeolocation.ready({
|
|
587
|
-
* app: {
|
|
588
|
-
* preventSuspend: true,
|
|
589
|
-
* heartbeatInterval: 60,
|
|
590
|
-
* }
|
|
591
|
-
* });
|
|
592
|
-
* ```
|
|
593
|
-
*
|
|
594
|
-
* **ℹ️ See also**
|
|
595
|
-
* - {@link AppConfig.heartbeatInterval}
|
|
596
|
-
* - {@link BackgroundGeolocation.onHeartbeat}
|
|
597
|
-
*/
|
|
598
17
|
preventSuspend?: boolean;
|
|
599
18
|
}
|