@transistorsoft/capacitor-background-geolocation 4.3.0 → 4.4.3
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/LICENSE +22 -0
- package/README.md +256 -87
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.33/tslocationmanager-3.1.33.aar → 3.1.35/tslocationmanager-3.1.35.aar} +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.aar.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/{3.1.33/tslocationmanager-3.1.33.pom → 3.1.35/tslocationmanager-3.1.35.pom} +1 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.35/tslocationmanager-3.1.35.pom.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager/maven-metadata.xml +4 -5
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/{3.1.33/tslocationmanager-reverse-3.1.33.aar → 3.1.35/tslocationmanager-reverse-3.1.35.aar} +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.aar.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/{3.1.33/tslocationmanager-reverse-3.1.33.pom → 3.1.35/tslocationmanager-reverse-3.1.35.pom} +1 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.md5 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha1 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha256 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.35/tslocationmanager-reverse-3.1.35.pom.sha512 +1 -0
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/maven-metadata.xml +4 -5
- package/android/src/main/java/com/transistorsoft/bggeo/capacitor/BackgroundGeolocationPlugin.java +7 -3
- package/dist/declarations/BackgroundGeolocation.d.ts +52 -32
- package/dist/declarations/Subscription.d.ts +104 -0
- package/dist/declarations/interfaces/Subscription.d.ts +104 -0
- package/dist/index.js +65 -44
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs.js +65 -44
- package/dist/plugin.cjs.js.map +1 -1
- package/ios/Plugin/BackgroundGeolocationModule.m +8 -6
- package/ios/TSLocationManager.xcframework/Info.plist +9 -9
- package/ios/TSLocationManager.xcframework/ios-arm64_armv7/TSLocationManager.framework/Info.plist +0 -0
- package/ios/TSLocationManager.xcframework/ios-arm64_armv7/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/Info.plist +0 -0
- package/ios/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/TSLocationManager.xcframework/ios-arm64_i386_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeResources +1 -1
- package/ios/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Resources/Info.plist +9 -9
- package/ios/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/TSLocationManager +0 -0
- package/package.json +1 -1
- package/CHANGELOG.md +0 -54
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.1.33/tslocationmanager-3.1.33.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-reverse/3.1.33/tslocationmanager-reverse-3.1.33.pom.sha512 +0 -1
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/// <reference path="interfaces/Authorization.d.ts" />
|
|
24
24
|
/// <reference path="interfaces/AuthorizationEvent.d.ts" />
|
|
25
25
|
/// <reference path="interfaces/TransistorAuthorizationToken.d.ts" />
|
|
26
|
-
///
|
|
26
|
+
/// <reference path="interfaces/Subscription.d.ts" />
|
|
27
27
|
declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
28
28
|
/**
|
|
29
29
|
* Primary API of the SDK.
|
|
@@ -253,6 +253,23 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
253
253
|
*/
|
|
254
254
|
static on(event: string, success:Function, failure?:Function):void;
|
|
255
255
|
/**
|
|
256
|
+
* @deprecated. Use [[Subscription]] returned from __`BackgroundGeolocation.onXXX`__ to remove listeners.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* const subscription = BackgroundGeolocation.onLocation((location) => {
|
|
261
|
+
* console.log('[onLocation]', location);
|
|
262
|
+
* });
|
|
263
|
+
* .
|
|
264
|
+
* .
|
|
265
|
+
* .
|
|
266
|
+
* // Remove listener
|
|
267
|
+
* subscription.remove();
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* ---------------------------------------------------------------------
|
|
271
|
+
* ### ⚠️ [Deprecated]
|
|
272
|
+
*
|
|
256
273
|
* Removes an event listener. You must supply the *type* of event to remove in addition to a reference to the *exact* function you
|
|
257
274
|
* used to subscribe to the event.
|
|
258
275
|
*
|
|
@@ -274,7 +291,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
274
291
|
*
|
|
275
292
|
* @example
|
|
276
293
|
* ```typescript
|
|
277
|
-
*
|
|
294
|
+
* const locationHandler = (location) => {
|
|
278
295
|
* console.log("[location] - ", location)
|
|
279
296
|
* }
|
|
280
297
|
* BackgroundGeolocation.onLocation(locationHandler)
|
|
@@ -293,7 +310,9 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
293
310
|
static un(event: string, handler: Function, success?:Function, failure?:Function): void;
|
|
294
311
|
|
|
295
312
|
/**
|
|
296
|
-
* Removes all event-listeners
|
|
313
|
+
* Removes all event-listeners.
|
|
314
|
+
*
|
|
315
|
+
* Calls [[Subscription.remove]] on all subscriptions.
|
|
297
316
|
*
|
|
298
317
|
* @example
|
|
299
318
|
* ```typescript
|
|
@@ -314,7 +333,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
314
333
|
*
|
|
315
334
|
* @example
|
|
316
335
|
* ```typescript
|
|
317
|
-
* BackgroundGeolocation.onLocation((location) => {
|
|
336
|
+
* const subscription = BackgroundGeolocation.onLocation((location) => {
|
|
318
337
|
* console.log("[onLocation] success: ", location);
|
|
319
338
|
* }, (error) => {
|
|
320
339
|
* console.log("[onLocation] ERROR: ", error);
|
|
@@ -333,7 +352,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
333
352
|
*
|
|
334
353
|
* @event location
|
|
335
354
|
*/
|
|
336
|
-
static onLocation(success: (location:Location)=>void, failure?:(errorCode: LocationError) => void):
|
|
355
|
+
static onLocation(success: (location:Location)=>void, failure?:(errorCode: LocationError) => void):Subscription;
|
|
337
356
|
|
|
338
357
|
/**
|
|
339
358
|
* Subscribe to Geofence transition events.
|
|
@@ -342,7 +361,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
342
361
|
*
|
|
343
362
|
* @example
|
|
344
363
|
* ```typescript
|
|
345
|
-
* BackgroundGeolocation.onGeofence((event) => {
|
|
364
|
+
* const subscription = BackgroundGeolocation.onGeofence((event) => {
|
|
346
365
|
* console.log("[onGeofence] ", event);
|
|
347
366
|
* });
|
|
348
367
|
* ```
|
|
@@ -352,7 +371,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
352
371
|
*
|
|
353
372
|
* @event geofence
|
|
354
373
|
*/
|
|
355
|
-
static onGeofence(callback: (event: GeofenceEvent) => void):
|
|
374
|
+
static onGeofence(callback: (event: GeofenceEvent) => void):Subscription;
|
|
356
375
|
|
|
357
376
|
/**
|
|
358
377
|
* Subscribe to __`motionchange`__ events.
|
|
@@ -362,7 +381,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
362
381
|
*
|
|
363
382
|
* @example
|
|
364
383
|
* ```typescript
|
|
365
|
-
* BackgroundGeolocation.onMotionChange((event) => {
|
|
384
|
+
* const subscription = BackgroundGeolocation.onMotionChange((event) => {
|
|
366
385
|
* if (event.isMoving) {
|
|
367
386
|
* console.log("[onMotionChange] Device has just started MOVING ", event.location);
|
|
368
387
|
* } else {
|
|
@@ -385,14 +404,14 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
385
404
|
*
|
|
386
405
|
* @event motionchange
|
|
387
406
|
*/
|
|
388
|
-
static onMotionChange(callback: (event:MotionChangeEvent) => void):
|
|
407
|
+
static onMotionChange(callback: (event:MotionChangeEvent) => void): Subscription;
|
|
389
408
|
|
|
390
409
|
/**
|
|
391
410
|
* Subscribe to HTTP responses from your server [[Config.url]].
|
|
392
411
|
*
|
|
393
412
|
* @example
|
|
394
413
|
* ```typescript
|
|
395
|
-
* BackgroundGeolocation.onHttp((response) => {
|
|
414
|
+
* const subscription = BackgroundGeolocation.onHttp((response) => {
|
|
396
415
|
* let status = response.status;
|
|
397
416
|
* let success = response.success;
|
|
398
417
|
* let responseText = response.responseText;
|
|
@@ -404,7 +423,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
404
423
|
*
|
|
405
424
|
* @event http
|
|
406
425
|
*/
|
|
407
|
-
static onHttp(callback: (response:HttpEvent) => void):
|
|
426
|
+
static onHttp(callback: (response:HttpEvent) => void): Subscription;
|
|
408
427
|
|
|
409
428
|
/**
|
|
410
429
|
* Subscribe to changes in motion activity.
|
|
@@ -416,13 +435,13 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
416
435
|
*
|
|
417
436
|
* @example
|
|
418
437
|
* ```typescript
|
|
419
|
-
* BackgroundGeolocation.onActivityChange((event) => {
|
|
438
|
+
* const subscription = BackgroundGeolocation.onActivityChange((event) => {
|
|
420
439
|
* console.log("[onActivityChange] ", event);
|
|
421
440
|
* });
|
|
422
441
|
* ```
|
|
423
442
|
* @event activitychange
|
|
424
443
|
*/
|
|
425
|
-
static onActivityChange(callback: (event: MotionActivityEvent) => void):
|
|
444
|
+
static onActivityChange(callback: (event: MotionActivityEvent) => void): Subscription;
|
|
426
445
|
|
|
427
446
|
/**
|
|
428
447
|
* Subscribe to changes in device's location-services configuration / authorization.
|
|
@@ -431,7 +450,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
431
450
|
*
|
|
432
451
|
* @example
|
|
433
452
|
* ```typescript
|
|
434
|
-
* BackgroundGeolocation.onProviderChange((event) => {
|
|
453
|
+
* const subscription = BackgroundGeolocation.onProviderChange((event) => {
|
|
435
454
|
* console.log("[onProviderChange: ", event);
|
|
436
455
|
*
|
|
437
456
|
* switch(event.status) {
|
|
@@ -459,7 +478,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
459
478
|
*
|
|
460
479
|
* @event providerchange
|
|
461
480
|
*/
|
|
462
|
-
static onProviderChange(callback: (event:ProviderChangeEvent) => void):
|
|
481
|
+
static onProviderChange(callback: (event:ProviderChangeEvent) => void): Subscription;
|
|
463
482
|
|
|
464
483
|
/**
|
|
465
484
|
* Subscribe to periodic heartbeat events.
|
|
@@ -469,10 +488,11 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
469
488
|
* @example
|
|
470
489
|
* ```typescript
|
|
471
490
|
* BackgroundGeolocation.ready({
|
|
472
|
-
* heartbeatInterval: 60
|
|
491
|
+
* heartbeatInterval: 60,
|
|
492
|
+
* preventSuspend: true // <-- Required for iOS
|
|
473
493
|
* });
|
|
474
494
|
*
|
|
475
|
-
* BackgroundGeolocation.onHeartbeat((event) => {
|
|
495
|
+
* const subscription = BackgroundGeolocation.onHeartbeat((event) => {
|
|
476
496
|
* console.log("[onHeartbeat] ", event);
|
|
477
497
|
*
|
|
478
498
|
* // You could request a new location if you wish.
|
|
@@ -489,7 +509,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
489
509
|
* - The [[Location]] provided by the [[HeartbeatEvent]] is only the last-known location. The *heartbeat* event does not actively engage location-services. If you wish to get the current location in your `callback`, use [[getCurrentPosition]].
|
|
490
510
|
* @event heartbeat
|
|
491
511
|
*/
|
|
492
|
-
static onHeartbeat(callback: (event: HeartbeatEvent) => void):
|
|
512
|
+
static onHeartbeat(callback: (event: HeartbeatEvent) => void): Subscription;
|
|
493
513
|
|
|
494
514
|
/**
|
|
495
515
|
* Subscribe to changes in actively monitored geofences.
|
|
@@ -508,7 +528,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
508
528
|
*
|
|
509
529
|
* @example
|
|
510
530
|
* ```typescript
|
|
511
|
-
* BackgroundGeolocation.onGeofencesChange((event) => {
|
|
531
|
+
* const subscription = BackgroundGeolocation.onGeofencesChange((event) => {
|
|
512
532
|
* let on = event.on; //<-- new geofences activated.
|
|
513
533
|
* let off = event.off; //<-- geofences that were just de-activated.
|
|
514
534
|
*
|
|
@@ -528,7 +548,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
528
548
|
* - 📘 [[Geofence | Geofencing Guide]]
|
|
529
549
|
* @event geofenceschange
|
|
530
550
|
*/
|
|
531
|
-
static onGeofencesChange(callback: (event: GeofencesChangeEvent) => void):
|
|
551
|
+
static onGeofencesChange(callback: (event: GeofencesChangeEvent) => void): Subscription;
|
|
532
552
|
|
|
533
553
|
/**
|
|
534
554
|
* Subscribe to [[schedule]] events.
|
|
@@ -538,7 +558,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
538
558
|
*
|
|
539
559
|
* @example
|
|
540
560
|
* ```typescript
|
|
541
|
-
* BackgroundGeolocation.onSchedule((state) => {
|
|
561
|
+
* const subscription = BackgroundGeolocation.onSchedule((state) => {
|
|
542
562
|
* if (state.enabled) {
|
|
543
563
|
* console.log("[onSchedule] scheduled start tracking");
|
|
544
564
|
* } else {
|
|
@@ -548,7 +568,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
548
568
|
* ```
|
|
549
569
|
* @event schedule
|
|
550
570
|
*/
|
|
551
|
-
static onSchedule(callback: (state:State) => void):
|
|
571
|
+
static onSchedule(callback: (state:State) => void): Subscription;
|
|
552
572
|
|
|
553
573
|
/**
|
|
554
574
|
* Subscribe to changes in network connectivity.
|
|
@@ -561,13 +581,13 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
561
581
|
*
|
|
562
582
|
* @example
|
|
563
583
|
* ```typescript
|
|
564
|
-
* BackgroundGeolocation.onConnectivityChange((event) => {
|
|
584
|
+
* const subscription = BackgroundGeolocation.onConnectivityChange((event) => {
|
|
565
585
|
* console.log("[onConnectivityChange] ", event);
|
|
566
586
|
* });
|
|
567
587
|
* ```
|
|
568
588
|
* @event connectivitychange
|
|
569
589
|
*/
|
|
570
|
-
static onConnectivityChange(callback: (event:ConnectivityChangeEvent) => void):
|
|
590
|
+
static onConnectivityChange(callback: (event:ConnectivityChangeEvent) => void): Subscription;
|
|
571
591
|
|
|
572
592
|
/**
|
|
573
593
|
* Subscribe to state changes in OS power-saving system.
|
|
@@ -592,13 +612,13 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
592
612
|
*
|
|
593
613
|
* @example
|
|
594
614
|
* ```typescript
|
|
595
|
-
* BackgroundGeolocation.onPowerSaveChange((isPowerSaveMode) => {
|
|
615
|
+
* const subscription = BackgroundGeolocation.onPowerSaveChange((isPowerSaveMode) => {
|
|
596
616
|
* console.log("[onPowerSaveChange: ", isPowerSaveMode);
|
|
597
617
|
* });
|
|
598
618
|
* ```
|
|
599
619
|
* @event powersavechange
|
|
600
620
|
*/
|
|
601
|
-
static onPowerSaveChange(callback: (enabled:boolean) => void):
|
|
621
|
+
static onPowerSaveChange(callback: (enabled:boolean) => void): Subscription;
|
|
602
622
|
|
|
603
623
|
/**
|
|
604
624
|
* Subscribe to changes in plugin [[State.enabled]].
|
|
@@ -609,18 +629,18 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
609
629
|
*
|
|
610
630
|
* @example
|
|
611
631
|
* ```typescript
|
|
612
|
-
* BackgroundGeolocation.onEnabledChange(isEnabled => {
|
|
632
|
+
* const subscription = BackgroundGeolocation.onEnabledChange(isEnabled => {
|
|
613
633
|
* console.log("[onEnabledChanged] isEnabled? ", isEnabled);
|
|
614
634
|
* });
|
|
615
635
|
* ```
|
|
616
636
|
* @event enabledchange
|
|
617
637
|
*/
|
|
618
|
-
static onEnabledChange(callback: (enabled:boolean) => void):
|
|
638
|
+
static onEnabledChange(callback: (enabled:boolean) => void): Subscription;
|
|
619
639
|
|
|
620
640
|
/**
|
|
621
641
|
* [__Android-only__] Subscribe to button-clicks of a custom [[Notification.layout]] on the Android foreground-service notification.
|
|
622
642
|
*/
|
|
623
|
-
static onNotificationAction(callback: (buttonId:string) => void):
|
|
643
|
+
static onNotificationAction(callback: (buttonId:string) => void): Subscription;
|
|
624
644
|
|
|
625
645
|
/**
|
|
626
646
|
* Subscribe to [[Authorization]] events.
|
|
@@ -632,7 +652,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
632
652
|
*
|
|
633
653
|
* @example
|
|
634
654
|
* ```typescript
|
|
635
|
-
* BackgroundGeolocation.onAuthorization((event) => {
|
|
655
|
+
* const subscription = BackgroundGeolocation.onAuthorization((event) => {
|
|
636
656
|
* if (event.success) {
|
|
637
657
|
* console.log("[authorization] ERROR: ", event.error);
|
|
638
658
|
* } else {
|
|
@@ -642,7 +662,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
642
662
|
* ```
|
|
643
663
|
*
|
|
644
664
|
*/
|
|
645
|
-
static onAuthorization(callback: (event:AuthorizationEvent) => void):
|
|
665
|
+
static onAuthorization(callback: (event:AuthorizationEvent) => void): Subscription;
|
|
646
666
|
|
|
647
667
|
/**
|
|
648
668
|
* Registers a Javascript callback to execute in the Android "Headless" state, where the app has been terminated configured with
|
|
@@ -656,7 +676,7 @@ declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
|
656
676
|
*
|
|
657
677
|
* @example
|
|
658
678
|
* ```typescript
|
|
659
|
-
*
|
|
679
|
+
* const BackgroundGeolocationHeadlessTask = async (event) => {
|
|
660
680
|
* let params = event.params;
|
|
661
681
|
* console.log("[BackgroundGeolocation HeadlessTask] -", event.name, params);
|
|
662
682
|
*
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
2
|
+
/**
|
|
3
|
+
* Object returned by BackgroundGeolocation event-listeners. `Subscription` contains just a single method [[remove]], used for removing an event-listener.
|
|
4
|
+
*
|
|
5
|
+
* - [[BackgroundGeolocation.onLocation]]
|
|
6
|
+
* - [[BackgroundGeolocation.onMotionChange]]
|
|
7
|
+
* - [[BackgroundGeolocation.onHttp]]
|
|
8
|
+
* - [[BackgroundGeolocation.onHeartbeat]]
|
|
9
|
+
* - [[BackgroundGeolocation.onProviderChange]]
|
|
10
|
+
* - [[BackgroundGeolocation.onActivityChange]]
|
|
11
|
+
* - [[BackgroundGeolocation.onGeofence]]
|
|
12
|
+
* - [[BackgroundGeolocation.onGeofencesChange]]
|
|
13
|
+
* - [[BackgroundGeolocation.onEnabledChange]]
|
|
14
|
+
* - [[BackgroundGeolocation.onConnectivityChange]]
|
|
15
|
+
* - [[BackgroundGeolocation.onSchedule]]
|
|
16
|
+
* - [[BackgroundGeolocation.onPowerSaveChange]]
|
|
17
|
+
* - [[BackgroundGeolocation.onNotificationAction]]
|
|
18
|
+
* - [[BackgroundGeolocation.onAuthorization]]
|
|
19
|
+
*
|
|
20
|
+
* In the past, one would remove event-listeners using the __now-deprectated__ [[BackgroundGeolocation.removeListener]].
|
|
21
|
+
*
|
|
22
|
+
* ## Removing an event-listener:
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Event-listeners return a Subscription instance, containing a .remove() method.
|
|
27
|
+
* const subscription = BackgroundGeolocation.onLocation(location => {
|
|
28
|
+
* console.log("[onLocation] ", location);
|
|
29
|
+
* });
|
|
30
|
+
* .
|
|
31
|
+
* .
|
|
32
|
+
* .
|
|
33
|
+
* // Later, to remove the event-listener:
|
|
34
|
+
* subscription.remove();
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* One might typically manage a collection of `Subscription` instances
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import BackgroundGeolocation, {
|
|
42
|
+
* Location,
|
|
43
|
+
* Subscription
|
|
44
|
+
* } from ...
|
|
45
|
+
*
|
|
46
|
+
* // Your custom Collection of Subscription instances.
|
|
47
|
+
* const SUBSCRIPTIONS = [];
|
|
48
|
+
*
|
|
49
|
+
* // Your custom method to push a Subscription instance.
|
|
50
|
+
* const subscribe = (subscription:Subscription) => {
|
|
51
|
+
* SUBSCRIPTIONS.push(subscription);
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // Your custom method to interate your SUBSCRIPTIONS and .remove each.
|
|
55
|
+
* const unsubscribe = () => {
|
|
56
|
+
* SUBSCRIPTIONS.forEach((subscription:Subscription) => subscription.remove());
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* const initBackgroundGeolocation = () {
|
|
60
|
+
* // Create event-listeners as usual, feeding the returned Subscription into
|
|
61
|
+
* // your custom subscribe() method.
|
|
62
|
+
* subscribe(BackgroundGeolocation.onLocation((location:Location) => {
|
|
63
|
+
* console.log('[onLocation]', location);
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* subscribe(BackgroundGeolocation.onMotionChange((location:Location) => {
|
|
67
|
+
* console.log('[onMotionChange]', location);
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* subscribe(BackgroundGeolocation.onEnabledChange((enabled:boolean) => {
|
|
71
|
+
* console.log('[onEnabledChange]', enabled);
|
|
72
|
+
* });
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* const onDestroyView = () => {
|
|
76
|
+
* // Call your custom unsubscribe method
|
|
77
|
+
* unsubscribe();
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
interface Subscription {
|
|
83
|
+
/**
|
|
84
|
+
* Removes a `BackgroundGeolocation` event-listener.
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // Event-listeners return a Subscription instance, containing a .remove() method.
|
|
88
|
+
* const onLocationSubscription = BackgroundGeolocation.onLocation(location => {
|
|
89
|
+
* console.log("[onLocation] ", location);
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* const onGeofenceSubscription = BackgroundGeolocation.onGeofence(event => {
|
|
93
|
+
* console.log("[onGeofence] ", event);
|
|
94
|
+
* });
|
|
95
|
+
* .
|
|
96
|
+
* .
|
|
97
|
+
* .
|
|
98
|
+
* // Later, removing event-listeners.
|
|
99
|
+
* onLocationSubscription.remove();
|
|
100
|
+
* onGeofenceSubscription.remove();
|
|
101
|
+
*/
|
|
102
|
+
remove():void;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
declare module "@transistorsoft/capacitor-background-geolocation" {
|
|
2
|
+
/**
|
|
3
|
+
* Object returned by BackgroundGeolocation event-listeners. `Subscription` contains just a single method [[remove]], used for removing an event-listener.
|
|
4
|
+
*
|
|
5
|
+
* - [[BackgroundGeolocation.onLocation]]
|
|
6
|
+
* - [[BackgroundGeolocation.onMotionChange]]
|
|
7
|
+
* - [[BackgroundGeolocation.onHttp]]
|
|
8
|
+
* - [[BackgroundGeolocation.onHeartbeat]]
|
|
9
|
+
* - [[BackgroundGeolocation.onProviderChange]]
|
|
10
|
+
* - [[BackgroundGeolocation.onActivityChange]]
|
|
11
|
+
* - [[BackgroundGeolocation.onGeofence]]
|
|
12
|
+
* - [[BackgroundGeolocation.onGeofencesChange]]
|
|
13
|
+
* - [[BackgroundGeolocation.onEnabledChange]]
|
|
14
|
+
* - [[BackgroundGeolocation.onConnectivityChange]]
|
|
15
|
+
* - [[BackgroundGeolocation.onSchedule]]
|
|
16
|
+
* - [[BackgroundGeolocation.onPowerSaveChange]]
|
|
17
|
+
* - [[BackgroundGeolocation.onNotificationAction]]
|
|
18
|
+
* - [[BackgroundGeolocation.onAuthorization]]
|
|
19
|
+
*
|
|
20
|
+
* In the past, one would remove event-listeners using the __now-deprectated__ [[BackgroundGeolocation.removeListener]].
|
|
21
|
+
*
|
|
22
|
+
* ## Removing an event-listener:
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Event-listeners return a Subscription instance, containing a .remove() method.
|
|
27
|
+
* const subscription = BackgroundGeolocation.onLocation(location => {
|
|
28
|
+
* console.log("[onLocation] ", location);
|
|
29
|
+
* });
|
|
30
|
+
* .
|
|
31
|
+
* .
|
|
32
|
+
* .
|
|
33
|
+
* // Later, to remove the event-listener:
|
|
34
|
+
* subscription.remove();
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* One might typically manage a collection of `Subscription` instances
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import BackgroundGeolocation, {
|
|
42
|
+
* Location,
|
|
43
|
+
* Subscription
|
|
44
|
+
* } from ...
|
|
45
|
+
*
|
|
46
|
+
* // Your custom Collection of Subscription instances.
|
|
47
|
+
* const SUBSCRIPTIONS = [];
|
|
48
|
+
*
|
|
49
|
+
* // Your custom method to push a Subscription instance.
|
|
50
|
+
* const subscribe = (subscription:Subscription) => {
|
|
51
|
+
* SUBSCRIPTIONS.push(subscription);
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // Your custom method to interate your SUBSCRIPTIONS and .remove each.
|
|
55
|
+
* const unsubscribe = () => {
|
|
56
|
+
* SUBSCRIPTIONS.forEach((subscription:Subscription) => subscription.remove());
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* const initBackgroundGeolocation = () {
|
|
60
|
+
* // Create event-listeners as usual, feeding the returned Subscription into
|
|
61
|
+
* // your custom subscribe() method.
|
|
62
|
+
* subscribe(BackgroundGeolocation.onLocation((location:Location) => {
|
|
63
|
+
* console.log('[onLocation]', location);
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* subscribe(BackgroundGeolocation.onMotionChange((location:Location) => {
|
|
67
|
+
* console.log('[onMotionChange]', location);
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* subscribe(BackgroundGeolocation.onEnabledChange((enabled:boolean) => {
|
|
71
|
+
* console.log('[onEnabledChange]', enabled);
|
|
72
|
+
* });
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* const onDestroyView = () => {
|
|
76
|
+
* // Call your custom unsubscribe method
|
|
77
|
+
* unsubscribe();
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
interface Subscription {
|
|
83
|
+
/**
|
|
84
|
+
* Removes a `BackgroundGeolocation` event-listener.
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* // Event-listeners return a Subscription instance, containing a .remove() method.
|
|
88
|
+
* const onLocationSubscription = BackgroundGeolocation.onLocation(location => {
|
|
89
|
+
* console.log("[onLocation] ", location);
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* const onGeofenceSubscription = BackgroundGeolocation.onGeofence(event => {
|
|
93
|
+
* console.log("[onGeofence] ", event);
|
|
94
|
+
* });
|
|
95
|
+
* .
|
|
96
|
+
* .
|
|
97
|
+
* .
|
|
98
|
+
* // Later, removing event-listeners.
|
|
99
|
+
* onLocationSubscription.remove();
|
|
100
|
+
* onGeofenceSubscription.remove();
|
|
101
|
+
*/
|
|
102
|
+
remove():void;
|
|
103
|
+
}
|
|
104
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -706,85 +706,106 @@ var BackgroundGeolocation = /** @class */ (function () {
|
|
|
706
706
|
/// Event Handling
|
|
707
707
|
///
|
|
708
708
|
BackgroundGeolocation.onLocation = function (success, failure) {
|
|
709
|
-
BackgroundGeolocation.addListener(Events.LOCATION, success, failure);
|
|
709
|
+
return BackgroundGeolocation.addListener(Events.LOCATION, success, failure);
|
|
710
710
|
};
|
|
711
711
|
BackgroundGeolocation.onMotionChange = function (success) {
|
|
712
|
-
BackgroundGeolocation.addListener(Events.MOTIONCHANGE, success);
|
|
712
|
+
return BackgroundGeolocation.addListener(Events.MOTIONCHANGE, success);
|
|
713
713
|
};
|
|
714
714
|
BackgroundGeolocation.onHttp = function (success) {
|
|
715
|
-
BackgroundGeolocation.addListener(Events.HTTP, success);
|
|
715
|
+
return BackgroundGeolocation.addListener(Events.HTTP, success);
|
|
716
716
|
};
|
|
717
717
|
BackgroundGeolocation.onHeartbeat = function (success) {
|
|
718
|
-
BackgroundGeolocation.addListener(Events.HEARTBEAT, success);
|
|
718
|
+
return BackgroundGeolocation.addListener(Events.HEARTBEAT, success);
|
|
719
719
|
};
|
|
720
720
|
BackgroundGeolocation.onProviderChange = function (success) {
|
|
721
|
-
BackgroundGeolocation.addListener(Events.PROVIDERCHANGE, success);
|
|
721
|
+
return BackgroundGeolocation.addListener(Events.PROVIDERCHANGE, success);
|
|
722
722
|
};
|
|
723
723
|
BackgroundGeolocation.onActivityChange = function (success) {
|
|
724
|
-
BackgroundGeolocation.addListener(Events.ACTIVITYCHANGE, success);
|
|
724
|
+
return BackgroundGeolocation.addListener(Events.ACTIVITYCHANGE, success);
|
|
725
725
|
};
|
|
726
726
|
BackgroundGeolocation.onGeofence = function (success) {
|
|
727
|
-
BackgroundGeolocation.addListener(Events.GEOFENCE, success);
|
|
727
|
+
return BackgroundGeolocation.addListener(Events.GEOFENCE, success);
|
|
728
728
|
};
|
|
729
729
|
BackgroundGeolocation.onGeofencesChange = function (success) {
|
|
730
|
-
BackgroundGeolocation.addListener(Events.GEOFENCESCHANGE, success);
|
|
730
|
+
return BackgroundGeolocation.addListener(Events.GEOFENCESCHANGE, success);
|
|
731
731
|
};
|
|
732
732
|
BackgroundGeolocation.onSchedule = function (success) {
|
|
733
|
-
BackgroundGeolocation.addListener(Events.SCHEDULE, success);
|
|
733
|
+
return BackgroundGeolocation.addListener(Events.SCHEDULE, success);
|
|
734
734
|
};
|
|
735
735
|
BackgroundGeolocation.onEnabledChange = function (success) {
|
|
736
|
-
BackgroundGeolocation.addListener(Events.ENABLEDCHANGE, success);
|
|
736
|
+
return BackgroundGeolocation.addListener(Events.ENABLEDCHANGE, success);
|
|
737
737
|
};
|
|
738
738
|
BackgroundGeolocation.onConnectivityChange = function (success) {
|
|
739
|
-
BackgroundGeolocation.addListener(Events.CONNECTIVITYCHANGE, success);
|
|
739
|
+
return BackgroundGeolocation.addListener(Events.CONNECTIVITYCHANGE, success);
|
|
740
740
|
};
|
|
741
741
|
BackgroundGeolocation.onPowerSaveChange = function (success) {
|
|
742
|
-
BackgroundGeolocation.addListener(Events.POWERSAVECHANGE, success);
|
|
742
|
+
return BackgroundGeolocation.addListener(Events.POWERSAVECHANGE, success);
|
|
743
743
|
};
|
|
744
744
|
BackgroundGeolocation.onNotificationAction = function (success) {
|
|
745
|
-
BackgroundGeolocation.addListener(Events.NOTIFICATIONACTION, success);
|
|
745
|
+
return BackgroundGeolocation.addListener(Events.NOTIFICATIONACTION, success);
|
|
746
746
|
};
|
|
747
747
|
BackgroundGeolocation.onAuthorization = function (success) {
|
|
748
|
-
BackgroundGeolocation.addListener(Events.AUTHORIZATION, success);
|
|
748
|
+
return BackgroundGeolocation.addListener(Events.AUTHORIZATION, success);
|
|
749
749
|
};
|
|
750
750
|
///
|
|
751
751
|
/// Listen to a plugin event
|
|
752
752
|
///
|
|
753
753
|
BackgroundGeolocation.addListener = function (event, success, failure) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
response = response.value;
|
|
765
|
-
}
|
|
766
|
-
if (response.hasOwnProperty("error") && (response.error != null)) {
|
|
767
|
-
if (typeof (failure) === 'function') {
|
|
768
|
-
failure(response.error);
|
|
769
|
-
}
|
|
770
|
-
else {
|
|
771
|
-
success(response);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
else {
|
|
775
|
-
success(response);
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
return [4 /*yield*/, NativeModule.addListener(event, handler)];
|
|
779
|
-
case 1:
|
|
780
|
-
listener = _a.sent();
|
|
781
|
-
EVENT_SUBSCRIPTIONS.push(new Subscription(event, listener, success));
|
|
782
|
-
return [2 /*return*/];
|
|
754
|
+
if (!Events[event.toUpperCase()]) {
|
|
755
|
+
throw (TAG + "#addListener - Unknown event '" + event + "'");
|
|
756
|
+
}
|
|
757
|
+
var handler = function (response) {
|
|
758
|
+
if (response.hasOwnProperty("value")) {
|
|
759
|
+
response = response.value;
|
|
760
|
+
}
|
|
761
|
+
if (response.hasOwnProperty("error") && (response.error != null)) {
|
|
762
|
+
if (typeof (failure) === 'function') {
|
|
763
|
+
failure(response.error);
|
|
783
764
|
}
|
|
784
|
-
|
|
765
|
+
else {
|
|
766
|
+
success(response);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
success(response);
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
// Create a flag to capture edge-case where the developer subscribes to an event then IMMEDIATELY calls subscription.remove()
|
|
774
|
+
// before NativeModule.addListener has resolved.
|
|
775
|
+
// The developer would have to do something weird like this:
|
|
776
|
+
// const subscription = BackgroundGeolocation.onLocation(this.onLocation);
|
|
777
|
+
// subscription.remove();
|
|
778
|
+
//
|
|
779
|
+
// The reason for this is I don't want developers to have to await calls to BackgroundGeolocation.onXXX(myHandler).
|
|
780
|
+
//
|
|
781
|
+
var isRemoved = false;
|
|
782
|
+
var subscriptionProxy = {
|
|
783
|
+
remove: function () {
|
|
784
|
+
// EmptyFn until NativeModule.addListener resolves and re-writes this function
|
|
785
|
+
isRemoved = true;
|
|
786
|
+
console.warn('[BackgroundGeolocation.addListener] Unexpected call to subscription.remove() on subscriptionProxy. Waiting for NativeModule.addListener to resolve.');
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
// Now add the listener and re-write subscriptionProxy.remove.
|
|
790
|
+
NativeModule.addListener(event, handler).then(function (listener) {
|
|
791
|
+
var subscription = new Subscription(event, listener, success);
|
|
792
|
+
EVENT_SUBSCRIPTIONS.push(subscription);
|
|
793
|
+
subscriptionProxy.remove = function () {
|
|
794
|
+
listener.remove();
|
|
795
|
+
// Remove from EVENT_SUBSCRIPTIONS.
|
|
796
|
+
if (EVENT_SUBSCRIPTIONS.indexOf(subscription) >= 0) {
|
|
797
|
+
EVENT_SUBSCRIPTIONS.splice(EVENT_SUBSCRIPTIONS.indexOf(subscription), 1);
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
if (isRemoved) {
|
|
801
|
+
// Caught edge-case. Developer added an event-handler then immediately call subscription.remove().
|
|
802
|
+
subscriptionProxy.remove();
|
|
803
|
+
}
|
|
785
804
|
});
|
|
805
|
+
return subscriptionProxy;
|
|
786
806
|
};
|
|
787
807
|
BackgroundGeolocation.removeListener = function (event, callback) {
|
|
808
|
+
console.warn('BackgroundGeolocation.removeListener is deprecated. Event-listener methods (eg: onLocation) now return a Subscription instance. Call subscription.remove() on the returned subscription instead. Eg:\nconst subscription = BackgroundGeolocation.onLocation(myLocationHandler)\n...\nsubscription.remove()');
|
|
788
809
|
return new Promise(function (resolve, reject) {
|
|
789
810
|
var found = null;
|
|
790
811
|
for (var n = 0, len = EVENT_SUBSCRIPTIONS.length; n < len; n++) {
|