@transistorsoft/background-geolocation-types 5.0.0-beta.3 → 5.0.0-beta.5
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 +3 -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 +1 -177
- 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 +1 -1
|
@@ -1,552 +1,11 @@
|
|
|
1
1
|
import { PersistMode } from '../../enums/PersistMode';
|
|
2
|
-
/**
|
|
3
|
-
* **Persistence / Storage Configuration**
|
|
4
|
-
*
|
|
5
|
-
* The **PersistenceConfig** group controls how the SDK stores, orders, and
|
|
6
|
-
* purges records in its on-device SQLite database. The database acts as a
|
|
7
|
-
* durable buffer between data producers (locations, geofences) and consumers
|
|
8
|
-
* (your app code and the HTTP service).
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* BackgroundGeolocation.ready({
|
|
12
|
-
* persistence: {
|
|
13
|
-
* maxDaysToPersist: 3,
|
|
14
|
-
* maxRecordsToPersist: 1000,
|
|
15
|
-
* extras: {
|
|
16
|
-
* 'user_id': 123,
|
|
17
|
-
* 'appVersion': '1.2.3'
|
|
18
|
-
* },
|
|
19
|
-
* persistMode: PersistMode.All
|
|
20
|
-
* }
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* The SDK **prefers an empty database**. Each new {@link Location} (and geofence
|
|
25
|
-
* event) is written to SQLite immediately, then consumed (and typically deleted)
|
|
26
|
-
* by downstream services such as the HTTP uploader. When a record is successfully
|
|
27
|
-
* processed (e.g., posted to your server), it is removed to keep the buffer
|
|
28
|
-
* small and responsive.
|
|
29
|
-
*
|
|
30
|
-
* Configure **PersistenceConfig** via {@link Config.persistence}.
|
|
31
|
-
*
|
|
32
|
-
* __What gets stored?__
|
|
33
|
-
*
|
|
34
|
-
* - **Locations** recorded by the tracker
|
|
35
|
-
* - **Geofence events** (enter / exit / dwell)
|
|
36
|
-
* - **Extras** merged at write time via {@link extras}
|
|
37
|
-
*
|
|
38
|
-
* __When are records deleted?__
|
|
39
|
-
*
|
|
40
|
-
* A record is deleted when **any** of the following occur:
|
|
41
|
-
*
|
|
42
|
-
* - Your server returns a `20x` for the HTTP upload (see {@link HttpConfig})
|
|
43
|
-
* - You call {@link BackgroundGeolocation.destroyLocations}
|
|
44
|
-
* - {@link maxDaysToPersist} elapses (rolling TTL purge)
|
|
45
|
-
* - {@link maxRecordsToPersist} would be exceeded
|
|
46
|
-
* (oldest records are dropped)
|
|
47
|
-
*
|
|
48
|
-
* Inspect pending records using:
|
|
49
|
-
*
|
|
50
|
-
* - {@link BackgroundGeolocation.getCount}
|
|
51
|
-
* - {@link BackgroundGeolocation.getLocations}
|
|
52
|
-
*
|
|
53
|
-
* __Ordering__
|
|
54
|
-
*
|
|
55
|
-
* The order in which records are selected for upload or consumption is controlled by
|
|
56
|
-
* {@link locationsOrderDirection}:
|
|
57
|
-
*
|
|
58
|
-
* - `"ASC"` → oldest first (default)
|
|
59
|
-
* - `"DESC"` → newest first
|
|
60
|
-
*
|
|
61
|
-
* __JSON templating__
|
|
62
|
-
*
|
|
63
|
-
* Customize the JSON structure of uploaded records:
|
|
64
|
-
*
|
|
65
|
-
* - {@link locationTemplate}
|
|
66
|
-
* - {@link geofenceTemplate}
|
|
67
|
-
*
|
|
68
|
-
* Templates receive the full record context and can reshape, rename, or nest fields
|
|
69
|
-
* to match backend requirements (see also {@link HttpConfig.rootProperty}).
|
|
70
|
-
*
|
|
71
|
-
* __Extras__
|
|
72
|
-
*
|
|
73
|
-
* {@link extras} is a free-form key/value map merged into **every**
|
|
74
|
-
* record when written. Ideal for static context such as `user_id`, `route_id`,
|
|
75
|
-
* `appVersion`, etc.
|
|
76
|
-
*
|
|
77
|
-
* __Persist mode__
|
|
78
|
-
*
|
|
79
|
-
* Control what is written to SQLite with {@link PersistMode}:
|
|
80
|
-
*
|
|
81
|
-
* - {@link PersistMode.All} — persist **locations + geofences**
|
|
82
|
-
* - {@link PersistMode.Location} — persist **locations only**
|
|
83
|
-
* - {@link PersistMode.Geofence} — persist **geofences only**
|
|
84
|
-
* - {@link PersistMode.None} — **do not persist** (live callbacks still fire)
|
|
85
|
-
*
|
|
86
|
-
* > Even with {@link PersistMode.None}, HTTP uploads can still occur if triggered
|
|
87
|
-
* > directly. Persistence controls the *buffer*, not the upload.
|
|
88
|
-
*
|
|
89
|
-
* __Example__
|
|
90
|
-
*
|
|
91
|
-
* ```ts
|
|
92
|
-
* const location = await bg.BackgroundGeolocation.getCurrentPosition({
|
|
93
|
-
* persist: true,
|
|
94
|
-
* extras: {"get_current_position": true},
|
|
95
|
-
* samples: 3,
|
|
96
|
-
* });
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* In this case, the fetched location is persisted (because `persist: true`,
|
|
100
|
-
* overriding {@link persistMode}), then uploaded immediately if
|
|
101
|
-
* {@link HttpConfig.autoSync} is enabled.
|
|
102
|
-
*
|
|
103
|
-
* __ProviderChange Records__
|
|
104
|
-
*
|
|
105
|
-
* Disable storage of diagnostic “provider change” records (GPS toggled, settings
|
|
106
|
-
* changed, etc.) with {@link disableProviderChangeRecord} to keep
|
|
107
|
-
* the database lean.
|
|
108
|
-
*
|
|
109
|
-
* __Examples__
|
|
110
|
-
*
|
|
111
|
-
* **Configure persistence behavior**
|
|
112
|
-
* ```ts
|
|
113
|
-
* const config = {
|
|
114
|
-
* persistence: {
|
|
115
|
-
* maxDaysToPersist: 14,
|
|
116
|
-
* maxRecordsToPersist: 5000,
|
|
117
|
-
* locationsOrderDirection: 'ASC',
|
|
118
|
-
* persistMode: PersistMode.All,
|
|
119
|
-
* extras: {'user_id': 123, 'appVersion': '1.2.3'},
|
|
120
|
-
* },
|
|
121
|
-
* http: {
|
|
122
|
-
* url: 'https://example.com/locations',
|
|
123
|
-
* autoSync: true,
|
|
124
|
-
* }
|
|
125
|
-
* });
|
|
126
|
-
* const state = await BackgroundGeolocation.ready(config);
|
|
127
|
-
* ```
|
|
128
|
-
*
|
|
129
|
-
* **Inspect and purge the database**
|
|
130
|
-
* ```ts
|
|
131
|
-
* final pending = await BackgroundGeolocation.getCount();
|
|
132
|
-
* console.log('Pending records: $pending');
|
|
133
|
-
*
|
|
134
|
-
* // Purge all records
|
|
135
|
-
* final ok = await bg.BackgroundGeolocation.destroyLocations();
|
|
136
|
-
* console.log('Destroyed all records? $ok');
|
|
137
|
-
* ```
|
|
138
|
-
*
|
|
139
|
-
* **Custom JSON templates**
|
|
140
|
-
* ```ts
|
|
141
|
-
* const config = {
|
|
142
|
-
* persistence: {
|
|
143
|
-
* locationTemplate: '''
|
|
144
|
-
* {
|
|
145
|
-
* "lat": <%= latitude %>,
|
|
146
|
-
* "lng": <%= longitude %>,
|
|
147
|
-
* "ts": "<%= timestamp %>",
|
|
148
|
-
* "meta": <%= JSON.stringify(extras) %>
|
|
149
|
-
* }
|
|
150
|
-
* ''',
|
|
151
|
-
* geofenceTemplate: '''
|
|
152
|
-
* {
|
|
153
|
-
* "id": "<%= identifier %>",
|
|
154
|
-
* "action": "<%= action %>",
|
|
155
|
-
* "ts": "<%= timestamp %>"
|
|
156
|
-
* }
|
|
157
|
-
* ''',
|
|
158
|
-
* },
|
|
159
|
-
* };
|
|
160
|
-
* ```
|
|
161
|
-
*
|
|
162
|
-
* __Migration from legacy flat Config__
|
|
163
|
-
*
|
|
164
|
-
* ```ts
|
|
165
|
-
* // Legacy
|
|
166
|
-
* {
|
|
167
|
-
* maxDaysToPersist: 14,
|
|
168
|
-
* maxRecordsToPersist: 5000,
|
|
169
|
-
* locationsOrderDirection: 'ASC',
|
|
170
|
-
* locationTemplate: '{...}',
|
|
171
|
-
* geofenceTemplate: '{...}',
|
|
172
|
-
* persistMode: Config.PERSIST_MODE_ALL,
|
|
173
|
-
* extras: {'user_id': 123},
|
|
174
|
-
* disableProviderChangeRecord: true,
|
|
175
|
-
* };
|
|
176
|
-
* ```
|
|
177
|
-
*
|
|
178
|
-
* Now grouped under **PersistenceConfig**:
|
|
179
|
-
*
|
|
180
|
-
* ```ts
|
|
181
|
-
* {
|
|
182
|
-
* persistence: {
|
|
183
|
-
* maxDaysToPersist: 14,
|
|
184
|
-
* maxRecordsToPersist: 5000,
|
|
185
|
-
* locationsOrderDirection: 'ASC',
|
|
186
|
-
* locationTemplate: '{...}',
|
|
187
|
-
* geofenceTemplate: '{...}',
|
|
188
|
-
* persistMode: PersistMode.all,
|
|
189
|
-
* extras: {'user_id': 123},
|
|
190
|
-
* disableProviderChangeRecord: true,
|
|
191
|
-
* },
|
|
192
|
-
* };
|
|
193
|
-
* ```
|
|
194
|
-
*
|
|
195
|
-
* Legacy keys remain but are marked **@deprecated**. Prefer the compound form going forward.
|
|
196
|
-
*
|
|
197
|
-
* @category Config
|
|
198
|
-
*/
|
|
199
2
|
export interface PersistenceConfig {
|
|
200
|
-
/**
|
|
201
|
-
* Optional custom template for rendering {@link Location} JSON request data
|
|
202
|
-
* in HTTP uploads.
|
|
203
|
-
*
|
|
204
|
-
* The {@link locationTemplate} is evaluated using
|
|
205
|
-
* Ruby-style ERB tags:
|
|
206
|
-
*
|
|
207
|
-
* ```erb
|
|
208
|
-
* <%= variable_name %>
|
|
209
|
-
* ```
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* ```ts
|
|
213
|
-
* BackgroundGeolocation.ready({
|
|
214
|
-
* persistence: {
|
|
215
|
-
* locationTemplate:
|
|
216
|
-
* '{"lat":<%= latitude %>,"lng":<%= longitude %>,"event":"<%= event %>",isMoving:<%= is_moving %>}'
|
|
217
|
-
* }
|
|
218
|
-
* });
|
|
219
|
-
*
|
|
220
|
-
* // Or use a compact Array template:
|
|
221
|
-
* BackgroundGeolocation.ready({
|
|
222
|
-
* persistence: {
|
|
223
|
-
* locationTemplate:
|
|
224
|
-
* '[<%=latitude%>, <%=longitude%>, "<%=event%>", <%=is_moving%>]'
|
|
225
|
-
* }
|
|
226
|
-
* });
|
|
227
|
-
* ```
|
|
228
|
-
*
|
|
229
|
-
* __⚠️ Quoting string data__
|
|
230
|
-
*
|
|
231
|
-
* The plugin does *not* automatically insert quotes around string values.
|
|
232
|
-
* Templates are JSON-encoded **exactly as written**.
|
|
233
|
-
*
|
|
234
|
-
* The following will cause a JSON error because `timestamp` is a string
|
|
235
|
-
* but is rendered unquoted:
|
|
236
|
-
*
|
|
237
|
-
* @example
|
|
238
|
-
* ```typescript
|
|
239
|
-
* BackgroundGeolocation.ready({
|
|
240
|
-
* persistence: {
|
|
241
|
-
* locationTemplate: '{"timestamp": <%= timestamp %>}'
|
|
242
|
-
* }
|
|
243
|
-
* });
|
|
244
|
-
* ```
|
|
245
|
-
*
|
|
246
|
-
* This renders invalid JSON:
|
|
247
|
-
*
|
|
248
|
-
* ```json
|
|
249
|
-
* {"timestamp": 2018-01-01T12:01:01.123Z}
|
|
250
|
-
* ```
|
|
251
|
-
*
|
|
252
|
-
* Correct usage:
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```typescript
|
|
256
|
-
* BackgroundGeolocation.ready({
|
|
257
|
-
* persistence: {
|
|
258
|
-
* locationTemplate: '{"timestamp": "<%= timestamp %>"}'
|
|
259
|
-
* }
|
|
260
|
-
* });
|
|
261
|
-
* ```
|
|
262
|
-
*
|
|
263
|
-
* ```json
|
|
264
|
-
* {"timestamp": "2018-01-01T12:01:01.123Z"}
|
|
265
|
-
* ```
|
|
266
|
-
*
|
|
267
|
-
* __Configured {@link PersistenceConfig.extras | extras}__
|
|
268
|
-
*
|
|
269
|
-
* If {@link extras} are configured, the key/value pairs are merged directly
|
|
270
|
-
* into the rendered location JSON.
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* ```typescript
|
|
274
|
-
* BackgroundGeolocation.ready({
|
|
275
|
-
* http: {
|
|
276
|
-
* url: 'https://my.server.com/locations',
|
|
277
|
-
* rootProperty: 'data',
|
|
278
|
-
* },
|
|
279
|
-
* persistence: {
|
|
280
|
-
* locationTemplate: '{"lat":<%= latitude %>,"lng":<%= longitude %>}',
|
|
281
|
-
* extras: { foo: "bar" }
|
|
282
|
-
* }
|
|
283
|
-
* });
|
|
284
|
-
* ```
|
|
285
|
-
*
|
|
286
|
-
* Produces:
|
|
287
|
-
*
|
|
288
|
-
* ```json
|
|
289
|
-
* {
|
|
290
|
-
* "data": {
|
|
291
|
-
* "lat": 23.23232323,
|
|
292
|
-
* "lng": 37.37373737,
|
|
293
|
-
* "foo": "bar"
|
|
294
|
-
* }
|
|
295
|
-
* }
|
|
296
|
-
* ```
|
|
297
|
-
*
|
|
298
|
-
* __Template Tags__
|
|
299
|
-
*
|
|
300
|
-
* | Tag | Type | Description |
|
|
301
|
-
* |------------------------|-----------|-------------|
|
|
302
|
-
* | `latitude` | `Float` | |
|
|
303
|
-
* | `longitude` | `Float` | |
|
|
304
|
-
* | `speed` | `Float` | Meters |
|
|
305
|
-
* | `heading` | `Float` | Degrees |
|
|
306
|
-
* | `accuracy` | `Float` | Meters |
|
|
307
|
-
* | `altitude` | `Float` | Meters |
|
|
308
|
-
* | `altitude_accuracy` | `Float` | Meters |
|
|
309
|
-
* | `timestamp` | `String` | ISO-8601 |
|
|
310
|
-
* | `uuid` | `String` | Unique ID |
|
|
311
|
-
* | `event` | `String` | `motionchange`, `geofence`, `heartbeat`, `providerchange` |
|
|
312
|
-
* | `odometer` | `Float` | Meters |
|
|
313
|
-
* | `activity.type` | `String` | `still`, `on_foot`, `running`, `on_bicycle`, `in_vehicle`, `unknown` |
|
|
314
|
-
* | `activity.confidence` | `Integer` | 0–100% |
|
|
315
|
-
* | `battery.level` | `Float` | 0–100% |
|
|
316
|
-
* | `battery.is_charging` | `Boolean` | Is device plugged in? |
|
|
317
|
-
* | `mock` | `Boolean` | True if generated by mock provider |
|
|
318
|
-
* | `is_moving` | `Boolean` | Device was moving when recorded |
|
|
319
|
-
* | `timestampMeta` | `Object` | Timestamp metadata; see {@link GeoConfig.enableTimestampMeta} |
|
|
320
|
-
*
|
|
321
|
-
* __ℹ️ See also__
|
|
322
|
-
* - {@link HttpEvent | HTTP Guide}
|
|
323
|
-
* - {@link geofenceTemplate}
|
|
324
|
-
* - {@link HttpConfig.rootProperty}
|
|
325
|
-
*/
|
|
326
3
|
locationTemplate?: string;
|
|
327
|
-
/**
|
|
328
|
-
* Optional custom template for rendering {@link GeofenceEvent}
|
|
329
|
-
* JSON request data in HTTP uploads.
|
|
330
|
-
*
|
|
331
|
-
* The {@link geofenceTemplate} behaves like
|
|
332
|
-
* {@link locationTemplate}, but includes two
|
|
333
|
-
* additional tags: `geofence.identifier` and `geofence.action`.
|
|
334
|
-
*
|
|
335
|
-
* The template is evaluated using Ruby-style ERB tags:
|
|
336
|
-
*
|
|
337
|
-
* ```erb
|
|
338
|
-
* <%= variable_name %>
|
|
339
|
-
* ```
|
|
340
|
-
*
|
|
341
|
-
* **ℹ️ See also**
|
|
342
|
-
* - {@link locationTemplate}
|
|
343
|
-
* - {@link HttpConfig.rootProperty}
|
|
344
|
-
* - {@link HttpEvent | HTTP Guide}
|
|
345
|
-
*
|
|
346
|
-
* @example
|
|
347
|
-
* ```typescript
|
|
348
|
-
* BackgroundGeolocation.ready({
|
|
349
|
-
* persistence: {
|
|
350
|
-
* geofenceTemplate:
|
|
351
|
-
* '{ "lat":<%= latitude %>, "lng":<%= longitude %>, "geofence":"<%= geofence.identifier %>:<%= geofence.action %>" }'
|
|
352
|
-
* }
|
|
353
|
-
* });
|
|
354
|
-
*
|
|
355
|
-
* // Or a compact Array form:
|
|
356
|
-
* BackgroundGeolocation.ready({
|
|
357
|
-
* persistence: {
|
|
358
|
-
* geofenceTemplate:
|
|
359
|
-
* '[<%= latitude %>, <%= longitude %>, "<%= geofence.identifier %>", "<%= geofence.action %>"]'
|
|
360
|
-
* }
|
|
361
|
-
* });
|
|
362
|
-
* ```
|
|
363
|
-
*
|
|
364
|
-
* __⚠️ Quoting string data__
|
|
365
|
-
*
|
|
366
|
-
* The plugin does *not* automatically apply double-quotes around string
|
|
367
|
-
* data. Templates are JSON-encoded **exactly as written**.
|
|
368
|
-
*
|
|
369
|
-
* Incorrect:
|
|
370
|
-
*
|
|
371
|
-
* ```typescript
|
|
372
|
-
* BackgroundGeolocation.ready({
|
|
373
|
-
* persistence: {
|
|
374
|
-
* geofenceTemplate: '{"timestamp": <%= timestamp %>}'
|
|
375
|
-
* }
|
|
376
|
-
* });
|
|
377
|
-
* ```
|
|
378
|
-
*
|
|
379
|
-
* Produces invalid JSON:
|
|
380
|
-
*
|
|
381
|
-
* ```json
|
|
382
|
-
* {"timestamp": 2018-01-01T12:01:01.123Z}
|
|
383
|
-
* ```
|
|
384
|
-
*
|
|
385
|
-
* Correct:
|
|
386
|
-
*
|
|
387
|
-
* ```typescript
|
|
388
|
-
* BackgroundGeolocation.ready({
|
|
389
|
-
* persistence: {
|
|
390
|
-
* geofenceTemplate: '{"timestamp": "<%= timestamp %>"}'
|
|
391
|
-
* }
|
|
392
|
-
* });
|
|
393
|
-
* ```
|
|
394
|
-
*
|
|
395
|
-
* ```json
|
|
396
|
-
* {"timestamp": "2018-01-01T12:01:01.123Z"}
|
|
397
|
-
* ```
|
|
398
|
-
*
|
|
399
|
-
* **Template Tags**
|
|
400
|
-
*
|
|
401
|
-
* Identical to {@link locationTemplate} with the
|
|
402
|
-
* following additions:
|
|
403
|
-
*
|
|
404
|
-
* | Tag | Type | Description |
|
|
405
|
-
* |--------------------------|----------|-------------|
|
|
406
|
-
* | `geofence.identifier` | `String` | Identifier of the activated geofence |
|
|
407
|
-
* | `geofence.action` | `String` | `"ENTER"` or `"EXIT"` |
|
|
408
|
-
* | `latitude` | `Float` | |
|
|
409
|
-
* | `longitude` | `Float` | |
|
|
410
|
-
* | `speed` | `Float` | Meters |
|
|
411
|
-
* | `heading` | `Float` | Degrees |
|
|
412
|
-
* | `accuracy` | `Float` | Meters |
|
|
413
|
-
* | `altitude` | `Float` | Meters |
|
|
414
|
-
* | `altitude_accuracy` | `Float` | Meters |
|
|
415
|
-
* | `timestamp` | `String` | ISO-8601 |
|
|
416
|
-
* | `uuid` | `String` | Unique ID |
|
|
417
|
-
* | `event` | `String` | `motionchange`, `geofence`, `heartbeat`, `providerchange` |
|
|
418
|
-
* | `odometer` | `Float` | Meters |
|
|
419
|
-
* | `activity.type` | `String` | `still`, `on_foot`, `running`, `on_bicycle`, `in_vehicle`, `unknown` |
|
|
420
|
-
* | `activity.confidence` | `Integer`| 0–100% |
|
|
421
|
-
* | `battery.level` | `Float` | 0–100% |
|
|
422
|
-
* | `battery.is_charging` | `Boolean`| Whether device is plugged in |
|
|
423
|
-
* | `mock` | `Boolean`| True when location was generated from a mock app |
|
|
424
|
-
* | `is_moving` | `Boolean`| True if recorded while in *moving* state |
|
|
425
|
-
* | `timestampMeta` | `Object` | Timestamp metadata; see {@link GeoConfig.enableTimestampMeta} |
|
|
426
|
-
*/
|
|
427
4
|
geofenceTemplate?: string;
|
|
428
|
-
/**
|
|
429
|
-
* Maximum number of days to retain a persisted geolocation record
|
|
430
|
-
* in the plugin’s on-device SQLite database.
|
|
431
|
-
*
|
|
432
|
-
* When your server fails to return **HTTP 200 OK**, the SDK will continue
|
|
433
|
-
* retrying uploads according to your {@link HttpConfig} settings. If a record
|
|
434
|
-
* remains unuploaded for longer than **maxDaysToPersist**, it will be
|
|
435
|
-
* permanently discarded to prevent unbounded database growth.
|
|
436
|
-
*
|
|
437
|
-
*/
|
|
438
5
|
maxDaysToPersist?: number;
|
|
439
|
-
/**
|
|
440
|
-
* Maximum number of records the SDK may retain in its on-device SQLite
|
|
441
|
-
* database.
|
|
442
|
-
*
|
|
443
|
-
* A value of `-1` (default) means **no limit**. When a limit is set and the
|
|
444
|
-
* number of stored records would exceed this value, the oldest records are
|
|
445
|
-
* purged to make room for the newest.
|
|
446
|
-
*
|
|
447
|
-
* See {@link HttpEvent} for details on upload behavior.
|
|
448
|
-
*/
|
|
449
6
|
maxRecordsToPersist?: number;
|
|
450
|
-
/**
|
|
451
|
-
* Sort order for persisted locations.
|
|
452
|
-
* `'ASC'` = oldest first; `'DESC'` = newest first.
|
|
453
|
-
*/
|
|
454
7
|
locationsOrderDirection?: 'ASC' | 'DESC';
|
|
455
|
-
/**
|
|
456
|
-
* Controls which event types the SDK will persist into its internal SQLite
|
|
457
|
-
* database: locations, geofences, or both.
|
|
458
|
-
*
|
|
459
|
-
* All recorded events are always delivered to their live callbacks
|
|
460
|
-
* ({@link BackgroundGeolocation.onLocation} and
|
|
461
|
-
* {@link BackgroundGeolocation.onGeofence}). This option only determines
|
|
462
|
-
* what is written to persistent storage. Events that are *not* persisted are
|
|
463
|
-
* also *not* eligible for HTTP uploads via {@link HttpConfig.url}.
|
|
464
|
-
*
|
|
465
|
-
* | Name | Description |
|
|
466
|
-
* |----------------------------------------------------------|-----------------------------------|
|
|
467
|
-
* | {@link PersistMode.All} | **Default** — persist both geofence and location events. |
|
|
468
|
-
* | {@link PersistMode.Location} | Persist **location** events only. |
|
|
469
|
-
* | {@link PersistMode.Geofence} | Persist **geofence** events only. |
|
|
470
|
-
* | {@link PersistMode.None} | Persist **nothing**. |
|
|
471
|
-
*
|
|
472
|
-
* __Warning__:
|
|
473
|
-
*
|
|
474
|
-
* This option is intended for specialized cases. For example, if you need
|
|
475
|
-
* continuous location tracking via {@link BackgroundGeolocation.start} but
|
|
476
|
-
* only want to *store* geofence events, configure:
|
|
477
|
-
* `persistMode: PersistMode.Geofence`.
|
|
478
|
-
*/
|
|
479
8
|
persistMode?: PersistMode;
|
|
480
|
-
/**
|
|
481
|
-
* Optional arbitrary key/value pairs merged into **each** recorded location.
|
|
482
|
-
*
|
|
483
|
-
* These values are persisted and included in all HTTP uploads, making them
|
|
484
|
-
* ideal for attaching contextual metadata such as `user_id`, `route_id`,
|
|
485
|
-
* or `session_id`.
|
|
486
|
-
*
|
|
487
|
-
* __See also:__
|
|
488
|
-
* - 📘 {@link HttpEvent | HTTP Guide}
|
|
489
|
-
*
|
|
490
|
-
* __Example:__
|
|
491
|
-
* ```typescript
|
|
492
|
-
* BackgroundGeolocation.ready({
|
|
493
|
-
* http: {
|
|
494
|
-
* url: "https://my-server.com/locations",
|
|
495
|
-
* params: {
|
|
496
|
-
* device_id: "abc123" // <-- appended to root JSON of each POST request
|
|
497
|
-
* }
|
|
498
|
-
* },
|
|
499
|
-
* persistence: {
|
|
500
|
-
* extras: {
|
|
501
|
-
* route_id: 1234 // <-- merged onto each location record
|
|
502
|
-
* }
|
|
503
|
-
* }
|
|
504
|
-
* });
|
|
505
|
-
* ```
|
|
506
|
-
*
|
|
507
|
-
* __Incoming request at your server:__
|
|
508
|
-
* ```json
|
|
509
|
-
* POST /locations
|
|
510
|
-
* {
|
|
511
|
-
* "device_id": "abc123", // from `params`
|
|
512
|
-
* "location": {
|
|
513
|
-
* "coords": {
|
|
514
|
-
* "latitude": 45.51927004945047,
|
|
515
|
-
* "longitude": -73.61650072045029
|
|
516
|
-
* },
|
|
517
|
-
* "extras": { // from `extras`
|
|
518
|
-
* "route_id": 1234
|
|
519
|
-
* }
|
|
520
|
-
* }
|
|
521
|
-
* }
|
|
522
|
-
* ```
|
|
523
|
-
*/
|
|
524
9
|
extras?: Record<string, any>;
|
|
525
|
-
/**
|
|
526
|
-
* __Android-only__
|
|
527
|
-
* Disable the automatic insertion of a synthetic “provider-change” location
|
|
528
|
-
* into the SDK’s SQLite database (and its subsequent HTTP upload).
|
|
529
|
-
*
|
|
530
|
-
* By default, when an {@link BackgroundGeolocation.onProviderChange} event fires, the Android SDK
|
|
531
|
-
* records a special location documenting *when* and *where* the device’s
|
|
532
|
-
* location-services state changed (e.g., GPS disabled).
|
|
533
|
-
* This behavior historically existed to support platforms with limited or
|
|
534
|
-
* unreliable Headless Task implementations (e.g., Cordova, Capacitor).
|
|
535
|
-
*
|
|
536
|
-
* Some developers have strict server-side JSON schemas or use
|
|
537
|
-
* {@link locationTemplate}, making it impossible to accept the automatically
|
|
538
|
-
* injected `provider` field. In these cases, set this flag to `true`.
|
|
539
|
-
*
|
|
540
|
-
* 
|
|
541
|
-
*
|
|
542
|
-
* __Example:__
|
|
543
|
-
* ```typescript
|
|
544
|
-
* BackgroundGeolocation.ready({
|
|
545
|
-
* persistence: {
|
|
546
|
-
* disableProviderChangeRecord: true
|
|
547
|
-
* }
|
|
548
|
-
* });
|
|
549
|
-
* ```
|
|
550
|
-
*/
|
|
551
10
|
disableProviderChangeRecord?: boolean;
|
|
552
11
|
}
|
|
@@ -1,61 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple device information, as returned by {@link BackgroundGeolocation.getDeviceInfo}.
|
|
3
|
-
*
|
|
4
|
-
* This provides basic model and platform info without needing external native dependencies.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* import BackgroundGeolocation from "react-native-background-geolocation";
|
|
9
|
-
*
|
|
10
|
-
* const info = await BackgroundGeolocation.getDeviceInfo();
|
|
11
|
-
* console.log(`[DeviceInfo] ${info.manufacturer} ${info.model} (${info.platform})`);
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @category Data
|
|
15
|
-
*/
|
|
16
1
|
export interface DeviceInfo {
|
|
17
|
-
/**
|
|
18
|
-
* Device model.
|
|
19
|
-
*
|
|
20
|
-
* Examples:
|
|
21
|
-
* - iPhone15,2
|
|
22
|
-
* - Pixel 8 Pro
|
|
23
|
-
*/
|
|
24
2
|
model: string;
|
|
25
|
-
/**
|
|
26
|
-
* Device manufacturer.
|
|
27
|
-
*
|
|
28
|
-
* Examples:
|
|
29
|
-
* - Apple
|
|
30
|
-
* - Google
|
|
31
|
-
* - Samsung
|
|
32
|
-
*/
|
|
33
3
|
manufacturer: string;
|
|
34
|
-
/**
|
|
35
|
-
* OS Version (human readable string).
|
|
36
|
-
*
|
|
37
|
-
* Examples:
|
|
38
|
-
* - "18.1"
|
|
39
|
-
* - "14"
|
|
40
|
-
* - "14.1.1"
|
|
41
|
-
*/
|
|
42
4
|
version: string;
|
|
43
|
-
/**
|
|
44
|
-
* OS platform name.
|
|
45
|
-
*
|
|
46
|
-
* One of:
|
|
47
|
-
* - `"iOS"`
|
|
48
|
-
* - `"Android"`
|
|
49
|
-
*/
|
|
50
5
|
platform: string;
|
|
51
|
-
/**
|
|
52
|
-
* Development framework hosting the SDK.
|
|
53
|
-
*
|
|
54
|
-
* For example:
|
|
55
|
-
* - `"react-native"`
|
|
56
|
-
* - `"capacitor"`
|
|
57
|
-
* - `"cordova"`
|
|
58
|
-
* - `"flutter"`
|
|
59
|
-
*/
|
|
60
6
|
framework: string;
|
|
61
7
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A geofence definition persisted by the SDK and monitored natively.
|
|
3
|
-
* @category Data
|
|
4
|
-
*/
|
|
5
1
|
export interface Geofence {
|
|
6
2
|
identifier: string;
|
|
7
3
|
latitude: number;
|
|
@@ -10,7 +6,6 @@ export interface Geofence {
|
|
|
10
6
|
notifyOnEntry?: boolean;
|
|
11
7
|
notifyOnExit?: boolean;
|
|
12
8
|
notifyOnDwell?: boolean;
|
|
13
|
-
/** ms; used when notifyOnDwell is true */
|
|
14
9
|
loiteringDelay?: number;
|
|
15
10
|
extras?: Record<string, unknown>;
|
|
16
11
|
}
|