@capgo/background-geolocation 7.0.9 → 7.0.11
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/README.md +161 -67
- package/android/src/main/java/com/capgo/capacitor_background_geolocation/BackgroundGeolocation.java +62 -0
- package/android/src/main/java/com/capgo/capacitor_background_geolocation/BackgroundGeolocationService.java +176 -0
- package/dist/docs.json +126 -30
- package/dist/esm/definitions.d.ts +74 -31
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +11 -1
- package/dist/esm/web.js +101 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +101 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +101 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Plugin.m +1 -0
- package/ios/Plugin/Plugin.swift +157 -0
- package/package.json +1 -1
package/dist/docs.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"api": {
|
|
3
3
|
"name": "BackgroundGeolocationPlugin",
|
|
4
4
|
"slug": "backgroundgeolocationplugin",
|
|
5
|
-
"docs": "Main plugin interface for background geolocation functionality.\nProvides methods to manage location
|
|
5
|
+
"docs": "Main plugin interface for background geolocation functionality.\nProvides methods to manage location updates and access device settings.",
|
|
6
6
|
"tags": [
|
|
7
7
|
{
|
|
8
|
-
"text": "
|
|
8
|
+
"text": "7.0.0",
|
|
9
9
|
"name": "since"
|
|
10
10
|
}
|
|
11
11
|
],
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"parameters": [
|
|
17
17
|
{
|
|
18
18
|
"name": "options",
|
|
19
|
-
"docs": "The
|
|
19
|
+
"docs": "The configuration options",
|
|
20
20
|
"type": "StartOptions"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"tags": [
|
|
30
30
|
{
|
|
31
31
|
"name": "param",
|
|
32
|
-
"text": "options The
|
|
32
|
+
"text": "options The configuration options"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"name": "param",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"name": "returns",
|
|
40
|
-
"text": "A promise that resolves
|
|
40
|
+
"text": "A promise that resolves when the method is successfully called"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"name": "since",
|
|
44
|
-
"text": "
|
|
44
|
+
"text": "7.0.9"
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
"name": "example",
|
|
48
48
|
"text": "await BackgroundGeolocation.start(\n {\n backgroundMessage: \"App is using your location in the background\",\n backgroundTitle: \"Location Service\",\n requestPermissions: true,\n stale: false,\n distanceFilter: 10\n },\n (location, error) => {\n if (error) {\n console.error('Location error:', error);\n return;\n }\n if (location) {\n console.log('New location:', location.latitude, location.longitude);\n }\n }\n);"
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
|
-
"docs": "
|
|
51
|
+
"docs": "To start listening for changes in the device's location, call this method.\nA Promise is returned to indicate that it finished the call. The callback will be called every time a new location\nis available, or if there was an error when calling this method. Don't rely on promise rejection for this.",
|
|
52
52
|
"complexTypes": [
|
|
53
53
|
"StartOptions",
|
|
54
54
|
"Location",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"tags": [
|
|
65
65
|
{
|
|
66
66
|
"name": "returns",
|
|
67
|
-
"text": "A promise that resolves when the
|
|
67
|
+
"text": "A promise that resolves when the plugin stops successfully removed"
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
"name": "since",
|
|
71
|
-
"text": "
|
|
71
|
+
"text": "7.0.9"
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
"name": "example",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
"name": "since",
|
|
94
|
-
"text": "
|
|
94
|
+
"text": "7.0.0"
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
97
|
"name": "example",
|
|
@@ -101,6 +101,41 @@
|
|
|
101
101
|
"docs": "Opens the device's location settings page.\nUseful for directing users to enable location services or adjust permissions.",
|
|
102
102
|
"complexTypes": [],
|
|
103
103
|
"slug": "opensettings"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "setPlannedRoute",
|
|
107
|
+
"signature": "(options: SetPlannedRouteOptions) => Promise<void>",
|
|
108
|
+
"parameters": [
|
|
109
|
+
{
|
|
110
|
+
"name": "options",
|
|
111
|
+
"docs": "The options for setting the planned route and sound file",
|
|
112
|
+
"type": "SetPlannedRouteOptions"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"returns": "Promise<void>",
|
|
116
|
+
"tags": [
|
|
117
|
+
{
|
|
118
|
+
"name": "param",
|
|
119
|
+
"text": "options The options for setting the planned route and sound file"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "returns",
|
|
123
|
+
"text": "A promise that resolves when the route is set successfully"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "since",
|
|
127
|
+
"text": "7.0.11"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "example",
|
|
131
|
+
"text": "await BackgroundGeolocation.setPlannedRoute({\n soundFile: \"notification.mp3\",\n route: [[-74.0060, 40.7128], [-118.2437, 34.0522]]\n});"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"docs": "Plays a sound file when the user deviates from the planned route.\nThis should be used to play a sound (in the background too, only for native).",
|
|
135
|
+
"complexTypes": [
|
|
136
|
+
"SetPlannedRouteOptions"
|
|
137
|
+
],
|
|
138
|
+
"slug": "setplannedroute"
|
|
104
139
|
}
|
|
105
140
|
],
|
|
106
141
|
"properties": []
|
|
@@ -112,7 +147,7 @@
|
|
|
112
147
|
"docs": "The options for configuring for location updates.",
|
|
113
148
|
"tags": [
|
|
114
149
|
{
|
|
115
|
-
"text": "
|
|
150
|
+
"text": "7.0.9",
|
|
116
151
|
"name": "since"
|
|
117
152
|
}
|
|
118
153
|
],
|
|
@@ -122,7 +157,7 @@
|
|
|
122
157
|
"name": "backgroundMessage",
|
|
123
158
|
"tags": [
|
|
124
159
|
{
|
|
125
|
-
"text": "
|
|
160
|
+
"text": "7.0.9",
|
|
126
161
|
"name": "since"
|
|
127
162
|
},
|
|
128
163
|
{
|
|
@@ -130,7 +165,7 @@
|
|
|
130
165
|
"name": "example"
|
|
131
166
|
}
|
|
132
167
|
],
|
|
133
|
-
"docs": "If the \"backgroundMessage\" option is defined, the
|
|
168
|
+
"docs": "If the \"backgroundMessage\" option is defined, the plugin will\nprovide location updates whether the app is in the background or the\nforeground. If it is not defined, location updates are only\nguaranteed in the foreground. This is true on both platforms.\n\nOn Android, a notification must be shown to continue receiving\nlocation updates in the background. This option specifies the text of\nthat notification.",
|
|
134
169
|
"complexTypes": [],
|
|
135
170
|
"type": "string | undefined"
|
|
136
171
|
},
|
|
@@ -138,7 +173,7 @@
|
|
|
138
173
|
"name": "backgroundTitle",
|
|
139
174
|
"tags": [
|
|
140
175
|
{
|
|
141
|
-
"text": "
|
|
176
|
+
"text": "7.0.9",
|
|
142
177
|
"name": "since"
|
|
143
178
|
},
|
|
144
179
|
{
|
|
@@ -158,7 +193,7 @@
|
|
|
158
193
|
"name": "requestPermissions",
|
|
159
194
|
"tags": [
|
|
160
195
|
{
|
|
161
|
-
"text": "
|
|
196
|
+
"text": "7.0.9",
|
|
162
197
|
"name": "since"
|
|
163
198
|
},
|
|
164
199
|
{
|
|
@@ -178,7 +213,7 @@
|
|
|
178
213
|
"name": "stale",
|
|
179
214
|
"tags": [
|
|
180
215
|
{
|
|
181
|
-
"text": "
|
|
216
|
+
"text": "7.0.9",
|
|
182
217
|
"name": "since"
|
|
183
218
|
},
|
|
184
219
|
{
|
|
@@ -198,7 +233,7 @@
|
|
|
198
233
|
"name": "distanceFilter",
|
|
199
234
|
"tags": [
|
|
200
235
|
{
|
|
201
|
-
"text": "
|
|
236
|
+
"text": "7.0.9",
|
|
202
237
|
"name": "since"
|
|
203
238
|
},
|
|
204
239
|
{
|
|
@@ -222,7 +257,7 @@
|
|
|
222
257
|
"docs": "Represents a geographical location with various attributes.\nContains all the standard location properties returned by GPS/network providers.",
|
|
223
258
|
"tags": [
|
|
224
259
|
{
|
|
225
|
-
"text": "
|
|
260
|
+
"text": "7.0.0",
|
|
226
261
|
"name": "since"
|
|
227
262
|
}
|
|
228
263
|
],
|
|
@@ -232,7 +267,7 @@
|
|
|
232
267
|
"name": "latitude",
|
|
233
268
|
"tags": [
|
|
234
269
|
{
|
|
235
|
-
"text": "
|
|
270
|
+
"text": "7.0.0",
|
|
236
271
|
"name": "since"
|
|
237
272
|
},
|
|
238
273
|
{
|
|
@@ -248,7 +283,7 @@
|
|
|
248
283
|
"name": "longitude",
|
|
249
284
|
"tags": [
|
|
250
285
|
{
|
|
251
|
-
"text": "
|
|
286
|
+
"text": "7.0.0",
|
|
252
287
|
"name": "since"
|
|
253
288
|
},
|
|
254
289
|
{
|
|
@@ -264,7 +299,7 @@
|
|
|
264
299
|
"name": "accuracy",
|
|
265
300
|
"tags": [
|
|
266
301
|
{
|
|
267
|
-
"text": "
|
|
302
|
+
"text": "7.0.0",
|
|
268
303
|
"name": "since"
|
|
269
304
|
},
|
|
270
305
|
{
|
|
@@ -280,7 +315,7 @@
|
|
|
280
315
|
"name": "altitude",
|
|
281
316
|
"tags": [
|
|
282
317
|
{
|
|
283
|
-
"text": "
|
|
318
|
+
"text": "7.0.0",
|
|
284
319
|
"name": "since"
|
|
285
320
|
},
|
|
286
321
|
{
|
|
@@ -296,7 +331,7 @@
|
|
|
296
331
|
"name": "altitudeAccuracy",
|
|
297
332
|
"tags": [
|
|
298
333
|
{
|
|
299
|
-
"text": "
|
|
334
|
+
"text": "7.0.0",
|
|
300
335
|
"name": "since"
|
|
301
336
|
},
|
|
302
337
|
{
|
|
@@ -312,7 +347,7 @@
|
|
|
312
347
|
"name": "simulated",
|
|
313
348
|
"tags": [
|
|
314
349
|
{
|
|
315
|
-
"text": "
|
|
350
|
+
"text": "7.0.0",
|
|
316
351
|
"name": "since"
|
|
317
352
|
},
|
|
318
353
|
{
|
|
@@ -328,7 +363,7 @@
|
|
|
328
363
|
"name": "bearing",
|
|
329
364
|
"tags": [
|
|
330
365
|
{
|
|
331
|
-
"text": "
|
|
366
|
+
"text": "7.0.0",
|
|
332
367
|
"name": "since"
|
|
333
368
|
},
|
|
334
369
|
{
|
|
@@ -344,7 +379,7 @@
|
|
|
344
379
|
"name": "speed",
|
|
345
380
|
"tags": [
|
|
346
381
|
{
|
|
347
|
-
"text": "
|
|
382
|
+
"text": "7.0.0",
|
|
348
383
|
"name": "since"
|
|
349
384
|
},
|
|
350
385
|
{
|
|
@@ -360,7 +395,7 @@
|
|
|
360
395
|
"name": "time",
|
|
361
396
|
"tags": [
|
|
362
397
|
{
|
|
363
|
-
"text": "
|
|
398
|
+
"text": "7.0.0",
|
|
364
399
|
"name": "since"
|
|
365
400
|
},
|
|
366
401
|
{
|
|
@@ -377,10 +412,10 @@
|
|
|
377
412
|
{
|
|
378
413
|
"name": "CallbackError",
|
|
379
414
|
"slug": "callbackerror",
|
|
380
|
-
"docs": "Error object that may be passed to the location
|
|
415
|
+
"docs": "Error object that may be passed to the location start callback.\nExtends the standard Error with optional error codes.",
|
|
381
416
|
"tags": [
|
|
382
417
|
{
|
|
383
|
-
"text": "
|
|
418
|
+
"text": "7.0.0",
|
|
384
419
|
"name": "since"
|
|
385
420
|
}
|
|
386
421
|
],
|
|
@@ -390,7 +425,7 @@
|
|
|
390
425
|
"name": "code",
|
|
391
426
|
"tags": [
|
|
392
427
|
{
|
|
393
|
-
"text": "
|
|
428
|
+
"text": "7.0.0",
|
|
394
429
|
"name": "since"
|
|
395
430
|
},
|
|
396
431
|
{
|
|
@@ -403,6 +438,67 @@
|
|
|
403
438
|
"type": "string | undefined"
|
|
404
439
|
}
|
|
405
440
|
]
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"name": "SetPlannedRouteOptions",
|
|
444
|
+
"slug": "setplannedrouteoptions",
|
|
445
|
+
"docs": "",
|
|
446
|
+
"tags": [],
|
|
447
|
+
"methods": [],
|
|
448
|
+
"properties": [
|
|
449
|
+
{
|
|
450
|
+
"name": "soundFile",
|
|
451
|
+
"tags": [
|
|
452
|
+
{
|
|
453
|
+
"text": "7.0.10",
|
|
454
|
+
"name": "since"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"text": "\"notification.mp3\"",
|
|
458
|
+
"name": "example"
|
|
459
|
+
}
|
|
460
|
+
],
|
|
461
|
+
"docs": "The name of the sound file to play.\nMust be a valid sound relative path in the app's public folder to work for both web and native platforms.\nThere's no need to include the public folder in the path.",
|
|
462
|
+
"complexTypes": [],
|
|
463
|
+
"type": "string"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
"name": "route",
|
|
467
|
+
"tags": [
|
|
468
|
+
{
|
|
469
|
+
"text": "7.0.11",
|
|
470
|
+
"name": "since"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"text": "[[-74.0060, 40.7128], [-118.2437, 34.0522]]",
|
|
474
|
+
"name": "example"
|
|
475
|
+
}
|
|
476
|
+
],
|
|
477
|
+
"docs": "The planned route as an array of longitude and latitude pairs.\nEach pair represents a point on the route.\nThis is used to define a route that the user can follow.\nThe route is used to play a sound when the user deviates from it.",
|
|
478
|
+
"complexTypes": [],
|
|
479
|
+
"type": "[number, number][]"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"name": "distance",
|
|
483
|
+
"tags": [
|
|
484
|
+
{
|
|
485
|
+
"text": "7.0.11",
|
|
486
|
+
"name": "since"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"text": "50",
|
|
490
|
+
"name": "default"
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"text": "50",
|
|
494
|
+
"name": "example"
|
|
495
|
+
}
|
|
496
|
+
],
|
|
497
|
+
"docs": "The distance in meters that the user must deviate from the planned route to trigger the sound.\nThis is used to determine how far off the route the user can be before the sound is played.\nIf not specified, a default value of 50 meters is used.",
|
|
498
|
+
"complexTypes": [],
|
|
499
|
+
"type": "number"
|
|
500
|
+
}
|
|
501
|
+
]
|
|
406
502
|
}
|
|
407
503
|
],
|
|
408
504
|
"enums": [],
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The options for configuring for location updates.
|
|
3
3
|
*
|
|
4
|
-
* @since
|
|
4
|
+
* @since 7.0.9
|
|
5
5
|
*/
|
|
6
6
|
export interface StartOptions {
|
|
7
7
|
/**
|
|
8
|
-
* If the "backgroundMessage" option is defined, the
|
|
8
|
+
* If the "backgroundMessage" option is defined, the plugin will
|
|
9
9
|
* provide location updates whether the app is in the background or the
|
|
10
10
|
* foreground. If it is not defined, location updates are only
|
|
11
11
|
* guaranteed in the foreground. This is true on both platforms.
|
|
@@ -14,14 +14,14 @@ export interface StartOptions {
|
|
|
14
14
|
* location updates in the background. This option specifies the text of
|
|
15
15
|
* that notification.
|
|
16
16
|
*
|
|
17
|
-
* @since
|
|
17
|
+
* @since 7.0.9
|
|
18
18
|
* @example "Getting your location to provide better service"
|
|
19
19
|
*/
|
|
20
20
|
backgroundMessage?: string;
|
|
21
21
|
/**
|
|
22
22
|
* The title of the notification mentioned above.
|
|
23
23
|
*
|
|
24
|
-
* @since
|
|
24
|
+
* @since 7.0.9
|
|
25
25
|
* @default "Using your location"
|
|
26
26
|
* @example "Location Service"
|
|
27
27
|
*/
|
|
@@ -30,7 +30,7 @@ export interface StartOptions {
|
|
|
30
30
|
* Whether permissions should be requested from the user automatically,
|
|
31
31
|
* if they are not already granted.
|
|
32
32
|
*
|
|
33
|
-
* @since
|
|
33
|
+
* @since 7.0.9
|
|
34
34
|
* @default true
|
|
35
35
|
* @example
|
|
36
36
|
* // Auto-request permissions
|
|
@@ -45,7 +45,7 @@ export interface StartOptions {
|
|
|
45
45
|
* obtains a GPS fix. You are responsible for checking the "time"
|
|
46
46
|
* property. If "false", locations are guaranteed to be up to date.
|
|
47
47
|
*
|
|
48
|
-
* @since
|
|
48
|
+
* @since 7.0.9
|
|
49
49
|
* @default false
|
|
50
50
|
* @example
|
|
51
51
|
* // Allow stale locations for faster initial response
|
|
@@ -59,7 +59,7 @@ export interface StartOptions {
|
|
|
59
59
|
* The distance in meters that the device must move before a new location update is triggered.
|
|
60
60
|
* This is used to filter out small movements and reduce the number of updates.
|
|
61
61
|
*
|
|
62
|
-
* @since
|
|
62
|
+
* @since 7.0.9
|
|
63
63
|
* @default 0
|
|
64
64
|
* @example
|
|
65
65
|
* // Update every 10 meters
|
|
@@ -74,14 +74,14 @@ export interface StartOptions {
|
|
|
74
74
|
* Represents a geographical location with various attributes.
|
|
75
75
|
* Contains all the standard location properties returned by GPS/network providers.
|
|
76
76
|
*
|
|
77
|
-
* @since
|
|
77
|
+
* @since 7.0.0
|
|
78
78
|
*/
|
|
79
79
|
export interface Location {
|
|
80
80
|
/**
|
|
81
81
|
* Latitude in degrees.
|
|
82
82
|
* Range: -90.0 to +90.0
|
|
83
83
|
*
|
|
84
|
-
* @since
|
|
84
|
+
* @since 7.0.0
|
|
85
85
|
* @example 40.7128
|
|
86
86
|
*/
|
|
87
87
|
latitude: number;
|
|
@@ -89,7 +89,7 @@ export interface Location {
|
|
|
89
89
|
* Longitude in degrees.
|
|
90
90
|
* Range: -180.0 to +180.0
|
|
91
91
|
*
|
|
92
|
-
* @since
|
|
92
|
+
* @since 7.0.0
|
|
93
93
|
* @example -74.0060
|
|
94
94
|
*/
|
|
95
95
|
longitude: number;
|
|
@@ -97,21 +97,21 @@ export interface Location {
|
|
|
97
97
|
* Radius of horizontal uncertainty in metres, with 68% confidence.
|
|
98
98
|
* Lower values indicate more accurate location.
|
|
99
99
|
*
|
|
100
|
-
* @since
|
|
100
|
+
* @since 7.0.0
|
|
101
101
|
* @example 5.0
|
|
102
102
|
*/
|
|
103
103
|
accuracy: number;
|
|
104
104
|
/**
|
|
105
105
|
* Metres above sea level (or null if not available).
|
|
106
106
|
*
|
|
107
|
-
* @since
|
|
107
|
+
* @since 7.0.0
|
|
108
108
|
* @example 10.5
|
|
109
109
|
*/
|
|
110
110
|
altitude: number | null;
|
|
111
111
|
/**
|
|
112
112
|
* Vertical uncertainty in metres, with 68% confidence (or null if not available).
|
|
113
113
|
*
|
|
114
|
-
* @since
|
|
114
|
+
* @since 7.0.0
|
|
115
115
|
* @example 3.0
|
|
116
116
|
*/
|
|
117
117
|
altitudeAccuracy: number | null;
|
|
@@ -119,7 +119,7 @@ export interface Location {
|
|
|
119
119
|
* `true` if the location was simulated by software, rather than GPS.
|
|
120
120
|
* Useful for detecting mock locations in development or testing.
|
|
121
121
|
*
|
|
122
|
-
* @since
|
|
122
|
+
* @since 7.0.0
|
|
123
123
|
* @example false
|
|
124
124
|
*/
|
|
125
125
|
simulated: boolean;
|
|
@@ -127,14 +127,14 @@ export interface Location {
|
|
|
127
127
|
* Deviation from true north in degrees (or null if not available).
|
|
128
128
|
* Range: 0.0 to 360.0
|
|
129
129
|
*
|
|
130
|
-
* @since
|
|
130
|
+
* @since 7.0.0
|
|
131
131
|
* @example 45.5
|
|
132
132
|
*/
|
|
133
133
|
bearing: number | null;
|
|
134
134
|
/**
|
|
135
135
|
* Speed in metres per second (or null if not available).
|
|
136
136
|
*
|
|
137
|
-
* @since
|
|
137
|
+
* @since 7.0.0
|
|
138
138
|
* @example 2.5
|
|
139
139
|
*/
|
|
140
140
|
speed: number | null;
|
|
@@ -142,43 +142,71 @@ export interface Location {
|
|
|
142
142
|
* Time the location was produced, in milliseconds since the unix epoch.
|
|
143
143
|
* Use this to check if a location is stale when using stale: true.
|
|
144
144
|
*
|
|
145
|
-
* @since
|
|
145
|
+
* @since 7.0.0
|
|
146
146
|
* @example 1640995200000
|
|
147
147
|
*/
|
|
148
148
|
time: number | null;
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
* Error object that may be passed to the location
|
|
151
|
+
* Error object that may be passed to the location start callback.
|
|
152
152
|
* Extends the standard Error with optional error codes.
|
|
153
153
|
*
|
|
154
|
-
* @since
|
|
154
|
+
* @since 7.0.0
|
|
155
155
|
*/
|
|
156
156
|
export interface CallbackError extends Error {
|
|
157
157
|
/**
|
|
158
158
|
* Optional error code for more specific error handling.
|
|
159
159
|
*
|
|
160
|
-
* @since
|
|
160
|
+
* @since 7.0.0
|
|
161
161
|
* @example "PERMISSION_DENIED"
|
|
162
162
|
*/
|
|
163
163
|
code?: string;
|
|
164
164
|
}
|
|
165
|
+
export interface SetPlannedRouteOptions {
|
|
166
|
+
/**
|
|
167
|
+
* The name of the sound file to play.
|
|
168
|
+
* Must be a valid sound relative path in the app's public folder to work for both web and native platforms.
|
|
169
|
+
* There's no need to include the public folder in the path.
|
|
170
|
+
* @since 7.0.10
|
|
171
|
+
* @example "notification.mp3"
|
|
172
|
+
* */
|
|
173
|
+
soundFile: string;
|
|
174
|
+
/**
|
|
175
|
+
* The planned route as an array of longitude and latitude pairs.
|
|
176
|
+
* Each pair represents a point on the route.
|
|
177
|
+
* This is used to define a route that the user can follow.
|
|
178
|
+
* The route is used to play a sound when the user deviates from it.
|
|
179
|
+
* @since 7.0.11
|
|
180
|
+
* @example [[-74.0060, 40.7128], [-118.2437, 34.0522]]
|
|
181
|
+
*/
|
|
182
|
+
route: [number, number][];
|
|
183
|
+
/**
|
|
184
|
+
* The distance in meters that the user must deviate from the planned route to trigger the sound.
|
|
185
|
+
* This is used to determine how far off the route the user can be before the sound is played.
|
|
186
|
+
* If not specified, a default value of 50 meters is used.
|
|
187
|
+
* @since 7.0.11
|
|
188
|
+
* @default 50
|
|
189
|
+
* @example 50
|
|
190
|
+
*/
|
|
191
|
+
distance: number;
|
|
192
|
+
}
|
|
165
193
|
/**
|
|
166
194
|
* Main plugin interface for background geolocation functionality.
|
|
167
|
-
* Provides methods to manage location
|
|
195
|
+
* Provides methods to manage location updates and access device settings.
|
|
168
196
|
*
|
|
169
|
-
* @since
|
|
197
|
+
* @since 7.0.0
|
|
170
198
|
*/
|
|
171
199
|
export interface BackgroundGeolocationPlugin {
|
|
172
200
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
201
|
+
* To start listening for changes in the device's location, call this method.
|
|
202
|
+
* A Promise is returned to indicate that it finished the call. The callback will be called every time a new location
|
|
203
|
+
* is available, or if there was an error when calling this method. Don't rely on promise rejection for this.
|
|
176
204
|
*
|
|
177
|
-
* @param options The
|
|
205
|
+
* @param options The configuration options
|
|
178
206
|
* @param callback The callback function invoked when a new location is available or an error occurs
|
|
179
|
-
* @returns A promise that resolves
|
|
207
|
+
* @returns A promise that resolves when the method is successfully called
|
|
180
208
|
*
|
|
181
|
-
* @since
|
|
209
|
+
* @since 7.0.9
|
|
182
210
|
* @example
|
|
183
211
|
* await BackgroundGeolocation.start(
|
|
184
212
|
* {
|
|
@@ -203,9 +231,9 @@ export interface BackgroundGeolocationPlugin {
|
|
|
203
231
|
/**
|
|
204
232
|
* Stops location updates.
|
|
205
233
|
*
|
|
206
|
-
* @returns A promise that resolves when the
|
|
234
|
+
* @returns A promise that resolves when the plugin stops successfully removed
|
|
207
235
|
*
|
|
208
|
-
* @since
|
|
236
|
+
* @since 7.0.9
|
|
209
237
|
* @example
|
|
210
238
|
* await BackgroundGeolocation.stop();
|
|
211
239
|
*/
|
|
@@ -216,10 +244,25 @@ export interface BackgroundGeolocationPlugin {
|
|
|
216
244
|
*
|
|
217
245
|
* @returns A promise that resolves when the settings page is opened
|
|
218
246
|
*
|
|
219
|
-
* @since
|
|
247
|
+
* @since 7.0.0
|
|
220
248
|
* @example
|
|
221
249
|
* // Direct user to location settings
|
|
222
250
|
* await BackgroundGeolocation.openSettings();
|
|
223
251
|
*/
|
|
224
252
|
openSettings(): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Plays a sound file when the user deviates from the planned route.
|
|
255
|
+
* This should be used to play a sound (in the background too, only for native).
|
|
256
|
+
*
|
|
257
|
+
* @param options The options for setting the planned route and sound file
|
|
258
|
+
* @returns A promise that resolves when the route is set successfully
|
|
259
|
+
*
|
|
260
|
+
* @since 7.0.11
|
|
261
|
+
* @example
|
|
262
|
+
* await BackgroundGeolocation.setPlannedRoute({
|
|
263
|
+
* soundFile: "notification.mp3",
|
|
264
|
+
* route: [[-74.0060, 40.7128], [-118.2437, 34.0522]]
|
|
265
|
+
* });
|
|
266
|
+
*/
|
|
267
|
+
setPlannedRoute(options: SetPlannedRouteOptions): Promise<void>;
|
|
225
268
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The options for configuring for location updates.\n *\n * @since
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The options for configuring for location updates.\n *\n * @since 7.0.9\n */\nexport interface StartOptions {\n /**\n * If the \"backgroundMessage\" option is defined, the plugin will\n * provide location updates whether the app is in the background or the\n * foreground. If it is not defined, location updates are only\n * guaranteed in the foreground. This is true on both platforms.\n *\n * On Android, a notification must be shown to continue receiving\n * location updates in the background. This option specifies the text of\n * that notification.\n *\n * @since 7.0.9\n * @example \"Getting your location to provide better service\"\n */\n backgroundMessage?: string;\n /**\n * The title of the notification mentioned above.\n *\n * @since 7.0.9\n * @default \"Using your location\"\n * @example \"Location Service\"\n */\n backgroundTitle?: string;\n /**\n * Whether permissions should be requested from the user automatically,\n * if they are not already granted.\n *\n * @since 7.0.9\n * @default true\n * @example\n * // Auto-request permissions\n * requestPermissions: true\n *\n * // Don't auto-request, handle manually\n * requestPermissions: false\n */\n requestPermissions?: boolean;\n /**\n * If \"true\", stale locations may be delivered while the device\n * obtains a GPS fix. You are responsible for checking the \"time\"\n * property. If \"false\", locations are guaranteed to be up to date.\n *\n * @since 7.0.9\n * @default false\n * @example\n * // Allow stale locations for faster initial response\n * stale: true\n *\n * // Only fresh locations\n * stale: false\n */\n stale?: boolean;\n /**\n * The distance in meters that the device must move before a new location update is triggered.\n * This is used to filter out small movements and reduce the number of updates.\n *\n * @since 7.0.9\n * @default 0\n * @example\n * // Update every 10 meters\n * distanceFilter: 10\n *\n * // Update on any movement\n * distanceFilter: 0\n */\n distanceFilter?: number;\n}\n\n/**\n * Represents a geographical location with various attributes.\n * Contains all the standard location properties returned by GPS/network providers.\n *\n * @since 7.0.0\n */\nexport interface Location {\n /**\n * Latitude in degrees.\n * Range: -90.0 to +90.0\n *\n * @since 7.0.0\n * @example 40.7128\n */\n latitude: number;\n /**\n * Longitude in degrees.\n * Range: -180.0 to +180.0\n *\n * @since 7.0.0\n * @example -74.0060\n */\n longitude: number;\n /**\n * Radius of horizontal uncertainty in metres, with 68% confidence.\n * Lower values indicate more accurate location.\n *\n * @since 7.0.0\n * @example 5.0\n */\n accuracy: number;\n /**\n * Metres above sea level (or null if not available).\n *\n * @since 7.0.0\n * @example 10.5\n */\n altitude: number | null;\n /**\n * Vertical uncertainty in metres, with 68% confidence (or null if not available).\n *\n * @since 7.0.0\n * @example 3.0\n */\n altitudeAccuracy: number | null;\n /**\n * `true` if the location was simulated by software, rather than GPS.\n * Useful for detecting mock locations in development or testing.\n *\n * @since 7.0.0\n * @example false\n */\n simulated: boolean;\n /**\n * Deviation from true north in degrees (or null if not available).\n * Range: 0.0 to 360.0\n *\n * @since 7.0.0\n * @example 45.5\n */\n bearing: number | null;\n /**\n * Speed in metres per second (or null if not available).\n *\n * @since 7.0.0\n * @example 2.5\n */\n speed: number | null;\n /**\n * Time the location was produced, in milliseconds since the unix epoch.\n * Use this to check if a location is stale when using stale: true.\n *\n * @since 7.0.0\n * @example 1640995200000\n */\n time: number | null;\n}\n\n/**\n * Error object that may be passed to the location start callback.\n * Extends the standard Error with optional error codes.\n *\n * @since 7.0.0\n */\nexport interface CallbackError extends Error {\n /**\n * Optional error code for more specific error handling.\n *\n * @since 7.0.0\n * @example \"PERMISSION_DENIED\"\n */\n code?: string;\n}\n\nexport interface SetPlannedRouteOptions {\n /**\n * The name of the sound file to play.\n * Must be a valid sound relative path in the app's public folder to work for both web and native platforms.\n * There's no need to include the public folder in the path.\n * @since 7.0.10\n * @example \"notification.mp3\"\n * */\n soundFile: string;\n /**\n * The planned route as an array of longitude and latitude pairs.\n * Each pair represents a point on the route.\n * This is used to define a route that the user can follow.\n * The route is used to play a sound when the user deviates from it.\n * @since 7.0.11\n * @example [[-74.0060, 40.7128], [-118.2437, 34.0522]]\n */\n route: [number, number][];\n\n /**\n * The distance in meters that the user must deviate from the planned route to trigger the sound.\n * This is used to determine how far off the route the user can be before the sound is played.\n * If not specified, a default value of 50 meters is used.\n * @since 7.0.11\n * @default 50\n * @example 50\n */\n distance: number;\n}\n\n/**\n * Main plugin interface for background geolocation functionality.\n * Provides methods to manage location updates and access device settings.\n *\n * @since 7.0.0\n */\nexport interface BackgroundGeolocationPlugin {\n /**\n * To start listening for changes in the device's location, call this method.\n * A Promise is returned to indicate that it finished the call. The callback will be called every time a new location\n * is available, or if there was an error when calling this method. Don't rely on promise rejection for this.\n *\n * @param options The configuration options\n * @param callback The callback function invoked when a new location is available or an error occurs\n * @returns A promise that resolves when the method is successfully called\n *\n * @since 7.0.9\n * @example\n * await BackgroundGeolocation.start(\n * {\n * backgroundMessage: \"App is using your location in the background\",\n * backgroundTitle: \"Location Service\",\n * requestPermissions: true,\n * stale: false,\n * distanceFilter: 10\n * },\n * (location, error) => {\n * if (error) {\n * console.error('Location error:', error);\n * return;\n * }\n * if (location) {\n * console.log('New location:', location.latitude, location.longitude);\n * }\n * }\n * );\n */\n start(\n options: StartOptions,\n callback: (position?: Location, error?: CallbackError) => void,\n ): Promise<void>;\n\n /**\n * Stops location updates.\n *\n * @returns A promise that resolves when the plugin stops successfully removed\n *\n * @since 7.0.9\n * @example\n * await BackgroundGeolocation.stop();\n */\n stop(): Promise<void>;\n\n /**\n * Opens the device's location settings page.\n * Useful for directing users to enable location services or adjust permissions.\n *\n * @returns A promise that resolves when the settings page is opened\n *\n * @since 7.0.0\n * @example\n * // Direct user to location settings\n * await BackgroundGeolocation.openSettings();\n */\n openSettings(): Promise<void>;\n\n /**\n * Plays a sound file when the user deviates from the planned route.\n * This should be used to play a sound (in the background too, only for native).\n *\n * @param options The options for setting the planned route and sound file\n * @returns A promise that resolves when the route is set successfully\n *\n * @since 7.0.11\n * @example\n * await BackgroundGeolocation.setPlannedRoute({\n * soundFile: \"notification.mp3\",\n * route: [[-74.0060, 40.7128], [-118.2437, 34.0522]]\n * });\n */\n setPlannedRoute(options: SetPlannedRouteOptions): Promise<void>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { WebPlugin } from "@capacitor/core";
|
|
2
|
-
import type { BackgroundGeolocationPlugin, StartOptions, Location, CallbackError } from "./definitions";
|
|
2
|
+
import type { BackgroundGeolocationPlugin, StartOptions, Location, CallbackError, SetPlannedRouteOptions } from "./definitions";
|
|
3
3
|
export declare class BackgroundGeolocationWeb extends WebPlugin implements BackgroundGeolocationPlugin {
|
|
4
|
+
private static readonly EARTH_RADIUS_M;
|
|
4
5
|
private watchId;
|
|
6
|
+
private plannedRoute;
|
|
7
|
+
private audio;
|
|
8
|
+
private isOffRoute;
|
|
9
|
+
private distanceThreshold;
|
|
5
10
|
start(options: StartOptions, callback: (position?: Location, error?: CallbackError) => void): Promise<void>;
|
|
6
11
|
stop(): Promise<void>;
|
|
7
12
|
openSettings(): Promise<void>;
|
|
13
|
+
setPlannedRoute(options: SetPlannedRouteOptions): Promise<void>;
|
|
14
|
+
private toRadians;
|
|
15
|
+
private haversine;
|
|
16
|
+
private distancePointToLineSegment;
|
|
17
|
+
private distancePointToRoute;
|
|
8
18
|
}
|