@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,579 +1,14 @@
|
|
|
1
1
|
import { HttpMethod } from '../../enums/HttpMethod';
|
|
2
|
-
/**
|
|
3
|
-
* **HTTP / Networking Configuration**
|
|
4
|
-
*
|
|
5
|
-
* The {@link HttpConfig} group controls how recorded locations are uploaded to
|
|
6
|
-
* your server. It defines the endpoint, HTTP verb, headers, params, batching
|
|
7
|
-
* behavior, and request timeouts.
|
|
8
|
-
*
|
|
9
|
-
* These options apply to all automatic syncs as well as manual syncs triggered
|
|
10
|
-
* by the app.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* BackgroundGeolocation.ready({
|
|
15
|
-
* http: {
|
|
16
|
-
* url: "https://example.com/locations",
|
|
17
|
-
* autoSync: true,
|
|
18
|
-
* params: { user_id: 1234 }
|
|
19
|
-
* }
|
|
20
|
-
* });
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* **Overview**
|
|
24
|
-
*
|
|
25
|
-
* The SDK persistently stores each recorded location in its internal SQLite
|
|
26
|
-
* database before attempting to upload it. The HTTP Service continuously consumes
|
|
27
|
-
* this queue of stored records in the background. For each record:
|
|
28
|
-
*
|
|
29
|
-
* 1. A **record-level lock** is acquired to prevent duplicate uploads.
|
|
30
|
-
* 2. The record is serialized into an HTTP request and posted to {@link url}.
|
|
31
|
-
* 3. A **2xx** response marks the record as delivered and it is deleted.
|
|
32
|
-
* 4. Failed or timed-out uploads remain locked until released for retry.
|
|
33
|
-
*
|
|
34
|
-
* The uploader operates automatically across:
|
|
35
|
-
*
|
|
36
|
-
* - background execution
|
|
37
|
-
* - app termination
|
|
38
|
-
* - device reboot
|
|
39
|
-
*
|
|
40
|
-
* When connectivity returns, it resumes processing any remaining records.
|
|
41
|
-
*
|
|
42
|
-
* | Area | Keys | Notes |
|
|
43
|
-
* |-----------------|----------------------------------------------|-------|
|
|
44
|
-
* | **Destination** | {@link url}, {@link method} | `method` defaults to `POST`. |
|
|
45
|
-
* | **Payload** | {@link rootProperty}, {@link params}, {@link headers} | Controls JSON body and headers. |
|
|
46
|
-
* | **Sync cadence** | {@link autoSync}, {@link autoSyncThreshold}, {@link batchSync}, {@link maxBatchSize} | Immediate vs batched uploads. |
|
|
47
|
-
* | **Network policy** | {@link disableAutoSyncOnCellular}, {@link timeout} | Conserve bandwidth and battery. |
|
|
48
|
-
*
|
|
49
|
-
* **How uploads work**
|
|
50
|
-
*
|
|
51
|
-
* 1. Each location is written to SQLite.
|
|
52
|
-
* 2. Pending records are locked for upload.
|
|
53
|
-
* 3. Locked records are sent to {@link url}.
|
|
54
|
-
* 4. On success (2xx), the record is deleted.
|
|
55
|
-
* 5. On failure, the record is unlocked and retried later.
|
|
56
|
-
*
|
|
57
|
-
* **The SQLite buffer**
|
|
58
|
-
*
|
|
59
|
-
* The storage acts as a rolling buffer and is normally empty. Records disappear
|
|
60
|
-
* when:
|
|
61
|
-
*
|
|
62
|
-
* - your server returns a 2xx (see {@link HttpEvent})
|
|
63
|
-
* - {@link BackgroundGeolocation.destroyLocations} is called
|
|
64
|
-
* - TTL from {@link PersistenceConfig.maxDaysToPersist} expires
|
|
65
|
-
* - {@link PersistenceConfig.maxRecordsToPersist} is exceeded
|
|
66
|
-
*
|
|
67
|
-
* Inspect queue size using {@link BackgroundGeolocation.getCount} or fetch with
|
|
68
|
-
* {@link BackgroundGeolocation.getLocations}.
|
|
69
|
-
*
|
|
70
|
-
* **Payload composition**
|
|
71
|
-
*
|
|
72
|
-
* - **Body:** JSON. If `batchSync` is `true`, an array of records is sent.
|
|
73
|
-
* If `rootProperty` is set, payload becomes:
|
|
74
|
-
*
|
|
75
|
-
* ```json
|
|
76
|
-
* { "<rootProperty>": [...] }
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* - **Headers:** Combined from {@link headers} plus authorization if
|
|
80
|
-
* configured.
|
|
81
|
-
*
|
|
82
|
-
* - **Params:** Added to every payload at the root or under `rootProperty`.
|
|
83
|
-
*
|
|
84
|
-
* Uploads use `application/json`; authorization refresh requests use
|
|
85
|
-
* `application/x-www-form-urlencoded`.
|
|
86
|
-
*
|
|
87
|
-
* **Sync strategy**
|
|
88
|
-
*
|
|
89
|
-
* - `autoSync`: upload after each record
|
|
90
|
-
* - `autoSyncThreshold`: wait for N records
|
|
91
|
-
* - `batchSync`: upload several records in one request
|
|
92
|
-
* - `maxBatchSize`: max records per batch
|
|
93
|
-
* - `timeout`: maximum HTTP duration
|
|
94
|
-
* - `disableAutoSyncOnCellular`: defer uploads until Wi-Fi
|
|
95
|
-
*
|
|
96
|
-
* **Error handling & retries**
|
|
97
|
-
*
|
|
98
|
-
* On non-2xx or network failure, records remain in queue and are retried when:
|
|
99
|
-
*
|
|
100
|
-
* - new locations arrive
|
|
101
|
-
* - app resumes / device boots
|
|
102
|
-
* - {@link BackgroundGeolocation.onConnectivityChange} fires
|
|
103
|
-
* - {@link BackgroundGeolocation.onHeartbeat} fires
|
|
104
|
-
* - iOS background fetch runs
|
|
105
|
-
*
|
|
106
|
-
* Or manually:
|
|
107
|
-
*
|
|
108
|
-
* ```ts
|
|
109
|
-
* await BackgroundGeolocation.sync();
|
|
110
|
-
* ```
|
|
111
|
-
*
|
|
112
|
-
* **HTTP Logging**
|
|
113
|
-
*
|
|
114
|
-
* Logs provide insight into HTTP behavior:
|
|
115
|
-
*
|
|
116
|
-
* ```text
|
|
117
|
-
* 📍 Location
|
|
118
|
-
* ✅ INSERT: record stored
|
|
119
|
-
* 🔒 Locked 1 records
|
|
120
|
-
* 🔵 HTTP POST
|
|
121
|
-
* 🔵 Response: 200
|
|
122
|
-
* ✅ DESTROY
|
|
123
|
-
* ```
|
|
124
|
-
*
|
|
125
|
-
* | # | Entry | Meaning |
|
|
126
|
-
* |:-:|---------------------------|---------|
|
|
127
|
-
* | 1 | `📍 Location` | Raw location recorded |
|
|
128
|
-
* | 2 | `INSERT` | Persisted to SQLite |
|
|
129
|
-
* | 3 | `Locked` | Marked for upload |
|
|
130
|
-
* | 4 | `HTTP POST/PUT` | Attempted upload |
|
|
131
|
-
* | 5 | `Response` | Server status |
|
|
132
|
-
* | 6 | `DESTROY` / `UNLOCK` | Success / failed retry |
|
|
133
|
-
*
|
|
134
|
-
* **Remote control via HTTP response (RPC)**
|
|
135
|
-
*
|
|
136
|
-
* Your server may instruct the SDK to execute commands by returning JSON
|
|
137
|
-
* containing a `background_geolocation` payload.
|
|
138
|
-
*
|
|
139
|
-
* **Multiple commands**
|
|
140
|
-
* ```json
|
|
141
|
-
* {
|
|
142
|
-
* "background_geolocation": [
|
|
143
|
-
* ["setConfig", { "geolocation": { "distanceFilter": 25 } }],
|
|
144
|
-
* ["start"]
|
|
145
|
-
* ]
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*
|
|
149
|
-
* **Single command**
|
|
150
|
-
* ```json
|
|
151
|
-
* { "background_geolocation": ["stop"] }
|
|
152
|
-
* ```
|
|
153
|
-
*
|
|
154
|
-
* **Supported remote commands**
|
|
155
|
-
*
|
|
156
|
-
* | Command | Arguments | Effect |
|
|
157
|
-
* |-------------------|----------------------------|--------|
|
|
158
|
-
* | `"start"` | — | {@link BackgroundGeolocation.start} |
|
|
159
|
-
* | `"stop"` | — | {@link BackgroundGeolocation.stop} |
|
|
160
|
-
* | `"startGeofences"`| — | {@link BackgroundGeolocation.startGeofences} |
|
|
161
|
-
* | `"changePace"` | boolean | {@link BackgroundGeolocation.changePace} |
|
|
162
|
-
* | `"setConfig"` | `{Config}` | {@link BackgroundGeolocation.setConfig} |
|
|
163
|
-
* | `"addGeofence"` | `{Geofence}` | {@link BackgroundGeolocation.addGeofence} |
|
|
164
|
-
* | `"addGeofences"` | `[{Geofence}, ...]` | {@link BackgroundGeolocation.addGeofences} |
|
|
165
|
-
* | `"removeGeofence"`| `identifier:string` | {@link BackgroundGeolocation.removeGeofence} |
|
|
166
|
-
* | `"removeGeofences"`| list or none | remove all or some |
|
|
167
|
-
* | `"uploadLog"` | `url:string` | upload plugin log |
|
|
168
|
-
* | `"destroyLog"` | — | delete plugin log |
|
|
169
|
-
*
|
|
170
|
-
* **Examples**
|
|
171
|
-
*
|
|
172
|
-
* Simple upload:
|
|
173
|
-
* ```ts
|
|
174
|
-
* BackgroundGeolocation.ready({
|
|
175
|
-
* http: {
|
|
176
|
-
* url: "https://api.example.com/locations",
|
|
177
|
-
* method: "POST",
|
|
178
|
-
* autoSync: true,
|
|
179
|
-
* headers: { Authorization: "Bearer secret" },
|
|
180
|
-
* params: { device_id: "abc-123" }
|
|
181
|
-
* }
|
|
182
|
-
* });
|
|
183
|
-
* ```
|
|
184
|
-
*
|
|
185
|
-
* Batched uploads:
|
|
186
|
-
* ```ts
|
|
187
|
-
* BackgroundGeolocation.ready({
|
|
188
|
-
* http: {
|
|
189
|
-
* url: "https://api.example.com/locations/bulk",
|
|
190
|
-
* autoSync: true,
|
|
191
|
-
* batchSync: true,
|
|
192
|
-
* maxBatchSize: 25,
|
|
193
|
-
* autoSyncThreshold: 10,
|
|
194
|
-
* rootProperty: "locations"
|
|
195
|
-
* }
|
|
196
|
-
* });
|
|
197
|
-
* ```
|
|
198
|
-
*
|
|
199
|
-
* Conserve cellular data:
|
|
200
|
-
* ```ts
|
|
201
|
-
* BackgroundGeolocation.ready({
|
|
202
|
-
* http: {
|
|
203
|
-
* url: "https://api.example.com/locations",
|
|
204
|
-
* autoSync: true,
|
|
205
|
-
* disableAutoSyncOnCellular: true
|
|
206
|
-
* }
|
|
207
|
-
* });
|
|
208
|
-
* ```
|
|
209
|
-
*
|
|
210
|
-
* Manual sync:
|
|
211
|
-
* ```ts
|
|
212
|
-
* await BackgroundGeolocation.setConfig({
|
|
213
|
-
* http: { url: "https://api.example.com", autoSync: false }
|
|
214
|
-
* });
|
|
215
|
-
*
|
|
216
|
-
* await BackgroundGeolocation.sync();
|
|
217
|
-
* ```
|
|
218
|
-
*
|
|
219
|
-
* **Migration from legacy flat Config**
|
|
220
|
-
*
|
|
221
|
-
* Old:
|
|
222
|
-
* ```ts
|
|
223
|
-
* BackgroundGeolocation.ready({
|
|
224
|
-
* url: "https://api.example.com",
|
|
225
|
-
* autoSync: true,
|
|
226
|
-
* headers: { Authorization: "Bearer ..." }
|
|
227
|
-
* });
|
|
228
|
-
* ```
|
|
229
|
-
*
|
|
230
|
-
* New (compound):
|
|
231
|
-
* ```ts
|
|
232
|
-
* BackgroundGeolocation.ready({
|
|
233
|
-
* http: {
|
|
234
|
-
* url: "https://api.example.com",
|
|
235
|
-
* autoSync: true,
|
|
236
|
-
* headers: { Authorization: "Bearer ..." }
|
|
237
|
-
* }
|
|
238
|
-
* });
|
|
239
|
-
* ```
|
|
240
|
-
*
|
|
241
|
-
* Legacy keys remain available but are **@deprecated** and will be removed in a
|
|
242
|
-
* future major release.
|
|
243
|
-
*
|
|
244
|
-
* @category Config
|
|
245
|
-
*/
|
|
246
2
|
export interface HttpConfig {
|
|
247
|
-
/**
|
|
248
|
-
* Server URL where you want the SDK to post recorded locations.
|
|
249
|
-
*
|
|
250
|
-
* Both the iOS and Android native code host their own robust HTTP service
|
|
251
|
-
* which can automatically upload recorded locations to your server. This is
|
|
252
|
-
* particularly important on **Android** when running headless with
|
|
253
|
-
* {@link AppConfig.stopOnTerminate} set to `false`, since only the plugin's
|
|
254
|
-
* background service continues running in that state.
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* ```ts
|
|
258
|
-
* // Listen to HTTP events.
|
|
259
|
-
* BackgroundGeolocation.onHttp((event) => {
|
|
260
|
-
* console.log("[onHttp]", event);
|
|
261
|
-
* });
|
|
262
|
-
*
|
|
263
|
-
* BackgroundGeolocation.ready({
|
|
264
|
-
* http: {
|
|
265
|
-
* url: "https://my-server.com/locations",
|
|
266
|
-
* params: {
|
|
267
|
-
* user_id: 1234
|
|
268
|
-
* },
|
|
269
|
-
* headers: {
|
|
270
|
-
* Authorization: "Basic my-secret-key"
|
|
271
|
-
* },
|
|
272
|
-
* autoSync: true,
|
|
273
|
-
* method: "POST"
|
|
274
|
-
* },
|
|
275
|
-
* app: {
|
|
276
|
-
* stopOnTerminate: false
|
|
277
|
-
* }
|
|
278
|
-
* });
|
|
279
|
-
* ```
|
|
280
|
-
*
|
|
281
|
-
* __Warning:__ It is highly recommended to let the SDK manage uploads to your
|
|
282
|
-
* server, **especially on Android** when {@link AppConfig.stopOnTerminate} is
|
|
283
|
-
* `false`. In that mode your application component *will* terminate—only the
|
|
284
|
-
* native Android background service continues operating, recording locations
|
|
285
|
-
* and posting them to your server. The SDK’s HTTP service automatically
|
|
286
|
-
* retries on failures and is more reliable for background delivery than
|
|
287
|
-
* ad-hoc HTTP requests from your own code.
|
|
288
|
-
*
|
|
289
|
-
* See the HTTP guide under {@link HttpConfig} for full examples, error
|
|
290
|
-
* handling, and payload structure.
|
|
291
|
-
*/
|
|
292
3
|
url?: string;
|
|
293
|
-
/**
|
|
294
|
-
* Optional HTTP headers applied to every outbound upload request.
|
|
295
|
-
*
|
|
296
|
-
* These headers are merged with the SDK’s automatically applied headers
|
|
297
|
-
* (such as `"content-type": "application/json"`). When using authorization,
|
|
298
|
-
* the SDK also injects an `Authorization` header as needed.
|
|
299
|
-
*
|
|
300
|
-
* @example
|
|
301
|
-
* ```ts
|
|
302
|
-
* BackgroundGeolocation.ready({
|
|
303
|
-
* http: {
|
|
304
|
-
* url: "https://my.server.com",
|
|
305
|
-
* headers: {
|
|
306
|
-
* Authorization: "Bearer <a secret key>",
|
|
307
|
-
* "X-FOO": "BAR"
|
|
308
|
-
* }
|
|
309
|
-
* }
|
|
310
|
-
* });
|
|
311
|
-
* ```
|
|
312
|
-
*
|
|
313
|
-
* Observing incoming requests at your server:
|
|
314
|
-
*
|
|
315
|
-
* ```text
|
|
316
|
-
* POST /locations
|
|
317
|
-
* {
|
|
318
|
-
* "host": "tracker.transistorsoft.com",
|
|
319
|
-
* "content-type": "application/json",
|
|
320
|
-
* "content-length": "456",
|
|
321
|
-
* ...
|
|
322
|
-
* "authorization": "Bearer <a secret key>",
|
|
323
|
-
* "X-FOO": "BAR"
|
|
324
|
-
* }
|
|
325
|
-
* ```
|
|
326
|
-
*
|
|
327
|
-
* **Note:**
|
|
328
|
-
* The SDK automatically applies several required headers, including:
|
|
329
|
-
* - `"content-type": "application/json"`
|
|
330
|
-
* - authorization headers when using {@link AuthorizationConfig}
|
|
331
|
-
*
|
|
332
|
-
* __See also:__ the **HTTP Guide** under {@link HttpConfig}.
|
|
333
|
-
*/
|
|
334
4
|
headers?: Record<string, string>;
|
|
335
|
-
/**
|
|
336
|
-
* Optional HTTP **`params`** appended to the JSON body of each outbound upload request.
|
|
337
|
-
*
|
|
338
|
-
* These key/value pairs are merged into the payload sent to your server
|
|
339
|
-
* (either at the root level or under `rootProperty`, if configured).
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```ts
|
|
343
|
-
* BackgroundGeolocation.ready({
|
|
344
|
-
* http: {
|
|
345
|
-
* url: "https://my-server.com/locations",
|
|
346
|
-
* params: {
|
|
347
|
-
* user_id: 1234,
|
|
348
|
-
* device_id: "abc123"
|
|
349
|
-
* }
|
|
350
|
-
* }
|
|
351
|
-
* });
|
|
352
|
-
* ```
|
|
353
|
-
*
|
|
354
|
-
* Example request body received by your server:
|
|
355
|
-
*
|
|
356
|
-
* ```json
|
|
357
|
-
* {
|
|
358
|
-
* "location": {
|
|
359
|
-
* "coords": {
|
|
360
|
-
* "latitude": 45.51927,
|
|
361
|
-
* "longitude": -73.61650
|
|
362
|
-
* // ...
|
|
363
|
-
* }
|
|
364
|
-
* },
|
|
365
|
-
* "user_id": 1234, // <-- params merged into the payload
|
|
366
|
-
* "device_id": "abc123"
|
|
367
|
-
* }
|
|
368
|
-
* ```
|
|
369
|
-
*
|
|
370
|
-
* __See also:__ the **HTTP Guide** under {@link HttpConfig}.
|
|
371
|
-
*/
|
|
372
5
|
params?: Record<string, any>;
|
|
373
|
-
/**
|
|
374
|
-
* The HTTP method used when uploading locations to your configured {@link url}.
|
|
375
|
-
*
|
|
376
|
-
* Defaults to **`POST`**.
|
|
377
|
-
*
|
|
378
|
-
* Valid values: **`POST`**, **`PUT`**, **`OPTIONS`**.
|
|
379
|
-
*
|
|
380
|
-
* @example
|
|
381
|
-
* ```ts
|
|
382
|
-
* BackgroundGeolocation.ready({
|
|
383
|
-
* http: {
|
|
384
|
-
* url: "https://my-server.com/locations",
|
|
385
|
-
* method: "PUT"
|
|
386
|
-
* }
|
|
387
|
-
* });
|
|
388
|
-
* ```
|
|
389
|
-
*/
|
|
390
6
|
method?: HttpMethod;
|
|
391
|
-
/**
|
|
392
|
-
* Immediately upload each recorded location to your configured {@link url}.
|
|
393
|
-
*
|
|
394
|
-
* Defaults to **`true`**.
|
|
395
|
-
*
|
|
396
|
-
* When `autoSync` is enabled and a {@link url} is provided, the SDK
|
|
397
|
-
* will attempt to upload each location **as soon as it is recorded**.
|
|
398
|
-
*
|
|
399
|
-
* If you set `autoSync: false`, you must manually call
|
|
400
|
-
* {@link BackgroundGeolocation.sync} to initiate uploads.
|
|
401
|
-
* Regardless of `autoSync`, *all* recorded locations are persisted in the
|
|
402
|
-
* SDK’s internal SQLite database until successfully delivered.
|
|
403
|
-
*
|
|
404
|
-
* __Note:__ The queue continues to grow until you call {@link BackgroundGeolocation.sync} or until uploads succeed.
|
|
405
|
-
*
|
|
406
|
-
* **See also**
|
|
407
|
-
* - {@link autoSyncThreshold}
|
|
408
|
-
* - {@link batchSync}
|
|
409
|
-
* - {@link maxBatchSize}
|
|
410
|
-
* - HTTP Guide at {@link HttpConfig}
|
|
411
|
-
*/
|
|
412
7
|
autoSync?: boolean;
|
|
413
|
-
/**
|
|
414
|
-
* The minimum number of persisted records the plugin must accumulate
|
|
415
|
-
* before triggering an automatic upload via {@link autoSync}.
|
|
416
|
-
*
|
|
417
|
-
* Defaults to **`0`** (no threshold).
|
|
418
|
-
*
|
|
419
|
-
* When set to a value greater than `0`, the SDK will wait until at least that
|
|
420
|
-
* many locations are recorded before uploading to your configured
|
|
421
|
-
* {@link url}.
|
|
422
|
-
*
|
|
423
|
-
* Using `autoSyncThreshold` together with {@link batchSync} can
|
|
424
|
-
* significantly **reduce battery consumption**, since batching minimizes the
|
|
425
|
-
* number of HTTP requests (which cost far more power than GPS work).
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
* __⚠️ Warning:__ Ignored during `onMotionChange`
|
|
429
|
-
*
|
|
430
|
-
* If you've configured `autoSyncThreshold`, it will be **ignored** during
|
|
431
|
-
* {@link BackgroundGeolocation.onMotionChange} transitions:
|
|
432
|
-
*
|
|
433
|
-
* - Entering the **moving** state:
|
|
434
|
-
* The device may have been dormant for a long time; the SDK eagerly uploads
|
|
435
|
-
* queued locations immediately.
|
|
436
|
-
*
|
|
437
|
-
* - Entering the **stationary** state:
|
|
438
|
-
* The device may *soon become* dormant; the SDK eagerly uploads all queued
|
|
439
|
-
* locations before going idle.
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
* **See also**
|
|
443
|
-
* - HTTP Guide at {@link HttpConfig}
|
|
444
|
-
*/
|
|
445
8
|
autoSyncThreshold?: number;
|
|
446
|
-
/**
|
|
447
|
-
* Disable {@link autoSync} when the device is connected over **cellular data**.
|
|
448
|
-
*
|
|
449
|
-
* Defaults to **`false`**.
|
|
450
|
-
*
|
|
451
|
-
* When set to **`true`**, automatic HTTP uploads will occur **only when on Wi-Fi**.
|
|
452
|
-
*
|
|
453
|
-
* This is useful for conserving mobile data usage, particularly when large
|
|
454
|
-
* batches of locations may accumulate while offline.
|
|
455
|
-
*
|
|
456
|
-
* __⚠️ Warning:__
|
|
457
|
-
* This option is **ignored** when manually invoking
|
|
458
|
-
* {@link BackgroundGeolocation.sync}. Manual syncs always proceed regardless of connection type.
|
|
459
|
-
*
|
|
460
|
-
* **See also**
|
|
461
|
-
* - {@link autoSync}
|
|
462
|
-
* - {@link BackgroundGeolocation.sync}
|
|
463
|
-
*/
|
|
464
9
|
disableAutoSyncOnCellular?: boolean;
|
|
465
|
-
/**
|
|
466
|
-
* Upload **multiple locations** to your {@link url} in a single HTTP request.
|
|
467
|
-
*
|
|
468
|
-
* Defaults to **`false`**.
|
|
469
|
-
* When set to **`true`**, the SDK will bundle **all currently queued locations** in
|
|
470
|
-
* the native SQLite database and upload them together in **one** HTTP request.
|
|
471
|
-
*
|
|
472
|
-
* When `batchSync` is **`false`**, the HTTP service performs **one request per
|
|
473
|
-
* location**, which can increase battery and network usage.
|
|
474
|
-
*
|
|
475
|
-
* Batching is often used together with {@link autoSyncThreshold} to
|
|
476
|
-
* reduce upload frequency and conserve power.
|
|
477
|
-
*
|
|
478
|
-
* **See also**
|
|
479
|
-
* - {@link url}
|
|
480
|
-
* - {@link autoSync}
|
|
481
|
-
* - {@link autoSyncThreshold}
|
|
482
|
-
* - **HTTP Guide** at {@link HttpConfig}
|
|
483
|
-
*/
|
|
484
10
|
batchSync?: boolean;
|
|
485
|
-
/**
|
|
486
|
-
* Controls the number of records attached to **each** batched HTTP request.
|
|
487
|
-
*
|
|
488
|
-
* Defaults to **`-1`** (no maximum).
|
|
489
|
-
*
|
|
490
|
-
* When using {@link batchSync} with {@link url} configured,
|
|
491
|
-
* this option limits how many queued location records may be included in a single
|
|
492
|
-
* HTTP request.
|
|
493
|
-
*
|
|
494
|
-
* If the number of queued records exceeds `maxBatchSize`, the SDK will generate
|
|
495
|
-
* **multiple HTTP requests** until the queue is fully drained.
|
|
496
|
-
*
|
|
497
|
-
* This prevents extremely large request bodies when the device has been offline
|
|
498
|
-
* for long periods (where megabytes of location data may accumulate).
|
|
499
|
-
*
|
|
500
|
-
* **See also**
|
|
501
|
-
* - {@link batchSync}
|
|
502
|
-
* - {@link url}
|
|
503
|
-
* - **HTTP Guide** at {@link HttpConfig}
|
|
504
|
-
*/
|
|
505
11
|
maxBatchSize?: number;
|
|
506
|
-
/**
|
|
507
|
-
* The root property of the JSON object where location data will be placed.
|
|
508
|
-
*
|
|
509
|
-
* When set, outgoing HTTP payloads will wrap the serialized location record(s)
|
|
510
|
-
* under the specified key.
|
|
511
|
-
*
|
|
512
|
-
* ```ts
|
|
513
|
-
* BackgroundGeolocation.ready({
|
|
514
|
-
* http: {
|
|
515
|
-
* rootProperty: "myData",
|
|
516
|
-
* url: "https://my.server.com",
|
|
517
|
-
* }
|
|
518
|
-
* });
|
|
519
|
-
* ```
|
|
520
|
-
*
|
|
521
|
-
* Produces payloads shaped like:
|
|
522
|
-
*
|
|
523
|
-
* ```json
|
|
524
|
-
* {
|
|
525
|
-
* "myData": {
|
|
526
|
-
* "coords": {
|
|
527
|
-
* "latitude": 23.232323,
|
|
528
|
-
* "longitude": 37.373737
|
|
529
|
-
* }
|
|
530
|
-
* }
|
|
531
|
-
* }
|
|
532
|
-
* ```
|
|
533
|
-
*
|
|
534
|
-
* If you specify `"."` (dot), the SDK places the data **directly in the root**
|
|
535
|
-
* of the JSON body:
|
|
536
|
-
*
|
|
537
|
-
* ```json
|
|
538
|
-
* {
|
|
539
|
-
* "coords": {
|
|
540
|
-
* "latitude": 23.232323,
|
|
541
|
-
* "longitude": 37.373737
|
|
542
|
-
* }
|
|
543
|
-
* }
|
|
544
|
-
* ```
|
|
545
|
-
*
|
|
546
|
-
* **Note:** See the **HTTP Guide** at {@link HttpConfig} for detailed payload
|
|
547
|
-
* examples and composition rules.
|
|
548
|
-
*
|
|
549
|
-
* **See also**
|
|
550
|
-
* - {@link PersistenceConfig.locationTemplate}
|
|
551
|
-
* - {@link PersistenceConfig.geofenceTemplate}
|
|
552
|
-
*/
|
|
553
12
|
rootProperty?: string;
|
|
554
|
-
/**
|
|
555
|
-
* HTTP request timeout in **milliseconds**.
|
|
556
|
-
*
|
|
557
|
-
* When an HTTP request exceeds this timeout, the SDK fires
|
|
558
|
-
* {@link BackgroundGeolocation.onHttp} with a failure event.
|
|
559
|
-
*
|
|
560
|
-
* Defaults to **`60000` ms**.
|
|
561
|
-
*
|
|
562
|
-
* @example
|
|
563
|
-
* ```ts
|
|
564
|
-
* BackgroundGeolocation.onHttp((response) => {
|
|
565
|
-
* if (!response.success) {
|
|
566
|
-
* console.log("[onHttp] FAILURE:", response);
|
|
567
|
-
* }
|
|
568
|
-
* });
|
|
569
|
-
*
|
|
570
|
-
* BackgroundGeolocation.ready({
|
|
571
|
-
* http: {
|
|
572
|
-
* url: "https://my-server.com/locations",
|
|
573
|
-
* timeout: 3000 // 3-second timeout
|
|
574
|
-
* }
|
|
575
|
-
* });
|
|
576
|
-
* ```
|
|
577
|
-
*/
|
|
578
13
|
timeout?: number;
|
|
579
14
|
}
|