@capgo/capacitor-ibeacon 8.1.0 → 8.1.2
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.
|
@@ -43,7 +43,7 @@ import org.altbeacon.beacon.Region;
|
|
|
43
43
|
)
|
|
44
44
|
public class CapacitorIbeaconPlugin extends Plugin implements BeaconConsumer {
|
|
45
45
|
|
|
46
|
-
private final String pluginVersion = "8.1.
|
|
46
|
+
private final String pluginVersion = "8.1.2";
|
|
47
47
|
private BeaconManager beaconManager;
|
|
48
48
|
private Map<String, Region> monitoredRegions = new HashMap<>();
|
|
49
49
|
private Map<String, Region> rangedRegions = new HashMap<>();
|
|
@@ -386,26 +386,108 @@ public class CapacitorIbeaconPlugin extends Plugin implements BeaconConsumer {
|
|
|
386
386
|
|
|
387
387
|
@PermissionCallback
|
|
388
388
|
private void bluetoothScanPermissionCallback(PluginCall call) {
|
|
389
|
-
//
|
|
390
|
-
|
|
389
|
+
// Check if BLUETOOTH_SCAN was granted
|
|
390
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
391
|
+
boolean hasBluetoothScan =
|
|
392
|
+
ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED;
|
|
393
|
+
|
|
394
|
+
if (hasBluetoothScan) {
|
|
395
|
+
// Continue with the original request
|
|
396
|
+
requestWhenInUseAuthorization(call);
|
|
397
|
+
} else {
|
|
398
|
+
// Permission denied, resolve with denied status
|
|
399
|
+
JSObject ret = new JSObject();
|
|
400
|
+
ret.put("status", "denied");
|
|
401
|
+
call.resolve(ret);
|
|
402
|
+
}
|
|
403
|
+
} else {
|
|
404
|
+
// Continue with the original request on older versions
|
|
405
|
+
requestWhenInUseAuthorization(call);
|
|
406
|
+
}
|
|
391
407
|
}
|
|
392
408
|
|
|
393
409
|
@PermissionCallback
|
|
394
410
|
private void bluetoothConnectPermissionCallback(PluginCall call) {
|
|
395
|
-
//
|
|
396
|
-
|
|
411
|
+
// Check if BLUETOOTH_CONNECT was granted
|
|
412
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
413
|
+
boolean hasBluetoothConnect =
|
|
414
|
+
ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.BLUETOOTH_CONNECT) ==
|
|
415
|
+
PackageManager.PERMISSION_GRANTED;
|
|
416
|
+
|
|
417
|
+
if (hasBluetoothConnect) {
|
|
418
|
+
// Continue with the original request
|
|
419
|
+
requestWhenInUseAuthorization(call);
|
|
420
|
+
} else {
|
|
421
|
+
// Permission denied, resolve with denied status
|
|
422
|
+
JSObject ret = new JSObject();
|
|
423
|
+
ret.put("status", "denied");
|
|
424
|
+
call.resolve(ret);
|
|
425
|
+
}
|
|
426
|
+
} else {
|
|
427
|
+
// Continue with the original request on older versions
|
|
428
|
+
requestWhenInUseAuthorization(call);
|
|
429
|
+
}
|
|
397
430
|
}
|
|
398
431
|
|
|
399
432
|
@PermissionCallback
|
|
400
433
|
private void bluetoothScanForBackgroundCallback(PluginCall call) {
|
|
401
|
-
//
|
|
402
|
-
|
|
434
|
+
// Check if BLUETOOTH_SCAN was granted
|
|
435
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
436
|
+
boolean hasBluetoothScan =
|
|
437
|
+
ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED;
|
|
438
|
+
|
|
439
|
+
if (hasBluetoothScan) {
|
|
440
|
+
// Continue with the background authorization flow
|
|
441
|
+
requestAlwaysAuthorization(call);
|
|
442
|
+
} else {
|
|
443
|
+
// Permission denied, check what we can offer
|
|
444
|
+
boolean hasFineLocation =
|
|
445
|
+
ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) ==
|
|
446
|
+
PackageManager.PERMISSION_GRANTED;
|
|
447
|
+
|
|
448
|
+
JSObject ret = new JSObject();
|
|
449
|
+
if (hasFineLocation) {
|
|
450
|
+
ret.put("status", "authorized_when_in_use");
|
|
451
|
+
} else {
|
|
452
|
+
ret.put("status", "denied");
|
|
453
|
+
}
|
|
454
|
+
call.resolve(ret);
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
// Continue with the background authorization flow on older versions
|
|
458
|
+
requestAlwaysAuthorization(call);
|
|
459
|
+
}
|
|
403
460
|
}
|
|
404
461
|
|
|
405
462
|
@PermissionCallback
|
|
406
463
|
private void bluetoothConnectForBackgroundCallback(PluginCall call) {
|
|
407
|
-
//
|
|
408
|
-
|
|
464
|
+
// Check if BLUETOOTH_CONNECT was granted
|
|
465
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
466
|
+
boolean hasBluetoothConnect =
|
|
467
|
+
ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.BLUETOOTH_CONNECT) ==
|
|
468
|
+
PackageManager.PERMISSION_GRANTED;
|
|
469
|
+
|
|
470
|
+
if (hasBluetoothConnect) {
|
|
471
|
+
// Continue with the background authorization flow
|
|
472
|
+
requestAlwaysAuthorization(call);
|
|
473
|
+
} else {
|
|
474
|
+
// Permission denied, check what we can offer
|
|
475
|
+
boolean hasFineLocation =
|
|
476
|
+
ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) ==
|
|
477
|
+
PackageManager.PERMISSION_GRANTED;
|
|
478
|
+
|
|
479
|
+
JSObject ret = new JSObject();
|
|
480
|
+
if (hasFineLocation) {
|
|
481
|
+
ret.put("status", "authorized_when_in_use");
|
|
482
|
+
} else {
|
|
483
|
+
ret.put("status", "denied");
|
|
484
|
+
}
|
|
485
|
+
call.resolve(ret);
|
|
486
|
+
}
|
|
487
|
+
} else {
|
|
488
|
+
// Continue with the background authorization flow on older versions
|
|
489
|
+
requestAlwaysAuthorization(call);
|
|
490
|
+
}
|
|
409
491
|
}
|
|
410
492
|
|
|
411
493
|
@PluginMethod
|
package/dist/docs.json
CHANGED
|
@@ -526,6 +526,254 @@
|
|
|
526
526
|
"BackgroundScanPeriodOptions"
|
|
527
527
|
],
|
|
528
528
|
"slug": "setbackgroundscanperiod"
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
"name": "addListener",
|
|
532
|
+
"signature": "(eventName: 'didRangeBeacons', listenerFunc: (data: RangingEventData) => void) => Promise<PluginListenerHandle>",
|
|
533
|
+
"parameters": [
|
|
534
|
+
{
|
|
535
|
+
"name": "eventName",
|
|
536
|
+
"docs": "- The event name ('didRangeBeacons')",
|
|
537
|
+
"type": "'didRangeBeacons'"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"name": "listenerFunc",
|
|
541
|
+
"docs": "- Callback function that receives beacon data",
|
|
542
|
+
"type": "(data: RangingEventData) => void"
|
|
543
|
+
}
|
|
544
|
+
],
|
|
545
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
546
|
+
"tags": [
|
|
547
|
+
{
|
|
548
|
+
"name": "param",
|
|
549
|
+
"text": "eventName - The event name ('didRangeBeacons')"
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"name": "param",
|
|
553
|
+
"text": "listenerFunc - Callback function that receives beacon data"
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
"name": "returns",
|
|
557
|
+
"text": "Promise that resolves with a PluginListenerHandle"
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
"name": "since",
|
|
561
|
+
"text": "1.0.0"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
"name": "example",
|
|
565
|
+
"text": "```typescript\nconst listener = await CapacitorIbeacon.addListener('didRangeBeacons', (data) => {\n console.log('Beacons:', data.beacons);\n});\n// Remove listener when done\nawait listener.remove();\n```"
|
|
566
|
+
}
|
|
567
|
+
],
|
|
568
|
+
"docs": "Listen for beacon ranging events.",
|
|
569
|
+
"complexTypes": [
|
|
570
|
+
"PluginListenerHandle",
|
|
571
|
+
"RangingEventData"
|
|
572
|
+
],
|
|
573
|
+
"slug": "addlistenerdidrangebeacons-"
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
"name": "addListener",
|
|
577
|
+
"signature": "(eventName: 'didEnterRegion', listenerFunc: (data: { region: BeaconRegion; }) => void) => Promise<PluginListenerHandle>",
|
|
578
|
+
"parameters": [
|
|
579
|
+
{
|
|
580
|
+
"name": "eventName",
|
|
581
|
+
"docs": "- The event name ('didEnterRegion')",
|
|
582
|
+
"type": "'didEnterRegion'"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
"name": "listenerFunc",
|
|
586
|
+
"docs": "- Callback function that receives region data",
|
|
587
|
+
"type": "(data: { region: BeaconRegion; }) => void"
|
|
588
|
+
}
|
|
589
|
+
],
|
|
590
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
591
|
+
"tags": [
|
|
592
|
+
{
|
|
593
|
+
"name": "param",
|
|
594
|
+
"text": "eventName - The event name ('didEnterRegion')"
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
"name": "param",
|
|
598
|
+
"text": "listenerFunc - Callback function that receives region data"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
"name": "returns",
|
|
602
|
+
"text": "Promise that resolves with a PluginListenerHandle"
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
"name": "since",
|
|
606
|
+
"text": "1.0.0"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
"name": "example",
|
|
610
|
+
"text": "```typescript\nconst listener = await CapacitorIbeacon.addListener('didEnterRegion', (data) => {\n console.log('Entered region:', data.region.identifier);\n});\n```"
|
|
611
|
+
}
|
|
612
|
+
],
|
|
613
|
+
"docs": "Listen for region enter events.",
|
|
614
|
+
"complexTypes": [
|
|
615
|
+
"PluginListenerHandle",
|
|
616
|
+
"BeaconRegion"
|
|
617
|
+
],
|
|
618
|
+
"slug": "addlistenerdidenterregion-"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"name": "addListener",
|
|
622
|
+
"signature": "(eventName: 'didExitRegion', listenerFunc: (data: { region: BeaconRegion; }) => void) => Promise<PluginListenerHandle>",
|
|
623
|
+
"parameters": [
|
|
624
|
+
{
|
|
625
|
+
"name": "eventName",
|
|
626
|
+
"docs": "- The event name ('didExitRegion')",
|
|
627
|
+
"type": "'didExitRegion'"
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
"name": "listenerFunc",
|
|
631
|
+
"docs": "- Callback function that receives region data",
|
|
632
|
+
"type": "(data: { region: BeaconRegion; }) => void"
|
|
633
|
+
}
|
|
634
|
+
],
|
|
635
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
636
|
+
"tags": [
|
|
637
|
+
{
|
|
638
|
+
"name": "param",
|
|
639
|
+
"text": "eventName - The event name ('didExitRegion')"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
"name": "param",
|
|
643
|
+
"text": "listenerFunc - Callback function that receives region data"
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
"name": "returns",
|
|
647
|
+
"text": "Promise that resolves with a PluginListenerHandle"
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"name": "since",
|
|
651
|
+
"text": "1.0.0"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"name": "example",
|
|
655
|
+
"text": "```typescript\nconst listener = await CapacitorIbeacon.addListener('didExitRegion', (data) => {\n console.log('Exited region:', data.region.identifier);\n});\n```"
|
|
656
|
+
}
|
|
657
|
+
],
|
|
658
|
+
"docs": "Listen for region exit events.",
|
|
659
|
+
"complexTypes": [
|
|
660
|
+
"PluginListenerHandle",
|
|
661
|
+
"BeaconRegion"
|
|
662
|
+
],
|
|
663
|
+
"slug": "addlistenerdidexitregion-"
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"name": "addListener",
|
|
667
|
+
"signature": "(eventName: 'didDetermineStateForRegion', listenerFunc: (data: MonitoringEventData) => void) => Promise<PluginListenerHandle>",
|
|
668
|
+
"parameters": [
|
|
669
|
+
{
|
|
670
|
+
"name": "eventName",
|
|
671
|
+
"docs": "- The event name ('didDetermineStateForRegion')",
|
|
672
|
+
"type": "'didDetermineStateForRegion'"
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
"name": "listenerFunc",
|
|
676
|
+
"docs": "- Callback function that receives region and state data",
|
|
677
|
+
"type": "(data: MonitoringEventData) => void"
|
|
678
|
+
}
|
|
679
|
+
],
|
|
680
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
681
|
+
"tags": [
|
|
682
|
+
{
|
|
683
|
+
"name": "param",
|
|
684
|
+
"text": "eventName - The event name ('didDetermineStateForRegion')"
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
"name": "param",
|
|
688
|
+
"text": "listenerFunc - Callback function that receives region and state data"
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
"name": "returns",
|
|
692
|
+
"text": "Promise that resolves with a PluginListenerHandle"
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"name": "since",
|
|
696
|
+
"text": "1.0.0"
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
"name": "example",
|
|
700
|
+
"text": "```typescript\nconst listener = await CapacitorIbeacon.addListener('didDetermineStateForRegion', (data) => {\n console.log('Region state:', data.state, 'for', data.region.identifier);\n});\n```"
|
|
701
|
+
}
|
|
702
|
+
],
|
|
703
|
+
"docs": "Listen for region state determination events.",
|
|
704
|
+
"complexTypes": [
|
|
705
|
+
"PluginListenerHandle",
|
|
706
|
+
"MonitoringEventData"
|
|
707
|
+
],
|
|
708
|
+
"slug": "addlistenerdiddeterminestateforregion-"
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
"name": "addListener",
|
|
712
|
+
"signature": "(eventName: 'monitoringDidFailForRegion', listenerFunc: (data: { region: BeaconRegion; error: string; }) => void) => Promise<PluginListenerHandle>",
|
|
713
|
+
"parameters": [
|
|
714
|
+
{
|
|
715
|
+
"name": "eventName",
|
|
716
|
+
"docs": "- The event name ('monitoringDidFailForRegion')",
|
|
717
|
+
"type": "'monitoringDidFailForRegion'"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"name": "listenerFunc",
|
|
721
|
+
"docs": "- Callback function that receives error data",
|
|
722
|
+
"type": "(data: { region: BeaconRegion; error: string; }) => void"
|
|
723
|
+
}
|
|
724
|
+
],
|
|
725
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
726
|
+
"tags": [
|
|
727
|
+
{
|
|
728
|
+
"name": "param",
|
|
729
|
+
"text": "eventName - The event name ('monitoringDidFailForRegion')"
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
"name": "param",
|
|
733
|
+
"text": "listenerFunc - Callback function that receives error data"
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
"name": "returns",
|
|
737
|
+
"text": "Promise that resolves with a PluginListenerHandle"
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
"name": "since",
|
|
741
|
+
"text": "1.0.0"
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
"name": "example",
|
|
745
|
+
"text": "```typescript\nconst listener = await CapacitorIbeacon.addListener('monitoringDidFailForRegion', (data) => {\n console.error('Monitoring failed:', data.error);\n});\n```"
|
|
746
|
+
}
|
|
747
|
+
],
|
|
748
|
+
"docs": "Listen for monitoring failure events.",
|
|
749
|
+
"complexTypes": [
|
|
750
|
+
"PluginListenerHandle",
|
|
751
|
+
"BeaconRegion"
|
|
752
|
+
],
|
|
753
|
+
"slug": "addlistenermonitoringdidfailforregion-"
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
"name": "removeAllListeners",
|
|
757
|
+
"signature": "() => Promise<void>",
|
|
758
|
+
"parameters": [],
|
|
759
|
+
"returns": "Promise<void>",
|
|
760
|
+
"tags": [
|
|
761
|
+
{
|
|
762
|
+
"name": "returns",
|
|
763
|
+
"text": "Promise that resolves when all listeners are removed"
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
"name": "since",
|
|
767
|
+
"text": "1.0.0"
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
"name": "example",
|
|
771
|
+
"text": "```typescript\nawait CapacitorIbeacon.removeAllListeners();\n```"
|
|
772
|
+
}
|
|
773
|
+
],
|
|
774
|
+
"docs": "Remove all listeners for this plugin.",
|
|
775
|
+
"complexTypes": [],
|
|
776
|
+
"slug": "removealllisteners"
|
|
529
777
|
}
|
|
530
778
|
],
|
|
531
779
|
"properties": []
|
|
@@ -641,6 +889,125 @@
|
|
|
641
889
|
"type": "number | undefined"
|
|
642
890
|
}
|
|
643
891
|
]
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
"name": "PluginListenerHandle",
|
|
895
|
+
"slug": "pluginlistenerhandle",
|
|
896
|
+
"docs": "",
|
|
897
|
+
"tags": [],
|
|
898
|
+
"methods": [],
|
|
899
|
+
"properties": [
|
|
900
|
+
{
|
|
901
|
+
"name": "remove",
|
|
902
|
+
"tags": [],
|
|
903
|
+
"docs": "",
|
|
904
|
+
"complexTypes": [],
|
|
905
|
+
"type": "() => Promise<void>"
|
|
906
|
+
}
|
|
907
|
+
]
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
"name": "RangingEventData",
|
|
911
|
+
"slug": "rangingeventdata",
|
|
912
|
+
"docs": "Event data when beacons are ranged.",
|
|
913
|
+
"tags": [],
|
|
914
|
+
"methods": [],
|
|
915
|
+
"properties": [
|
|
916
|
+
{
|
|
917
|
+
"name": "region",
|
|
918
|
+
"tags": [],
|
|
919
|
+
"docs": "Region that was ranged.",
|
|
920
|
+
"complexTypes": [
|
|
921
|
+
"BeaconRegion"
|
|
922
|
+
],
|
|
923
|
+
"type": "BeaconRegion"
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
"name": "beacons",
|
|
927
|
+
"tags": [],
|
|
928
|
+
"docs": "Array of detected beacons.",
|
|
929
|
+
"complexTypes": [
|
|
930
|
+
"Beacon"
|
|
931
|
+
],
|
|
932
|
+
"type": "Beacon[]"
|
|
933
|
+
}
|
|
934
|
+
]
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
"name": "Beacon",
|
|
938
|
+
"slug": "beacon",
|
|
939
|
+
"docs": "Detected beacon information.",
|
|
940
|
+
"tags": [],
|
|
941
|
+
"methods": [],
|
|
942
|
+
"properties": [
|
|
943
|
+
{
|
|
944
|
+
"name": "uuid",
|
|
945
|
+
"tags": [],
|
|
946
|
+
"docs": "Beacon UUID.",
|
|
947
|
+
"complexTypes": [],
|
|
948
|
+
"type": "string"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
"name": "major",
|
|
952
|
+
"tags": [],
|
|
953
|
+
"docs": "Major value.",
|
|
954
|
+
"complexTypes": [],
|
|
955
|
+
"type": "number"
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
"name": "minor",
|
|
959
|
+
"tags": [],
|
|
960
|
+
"docs": "Minor value.",
|
|
961
|
+
"complexTypes": [],
|
|
962
|
+
"type": "number"
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
"name": "rssi",
|
|
966
|
+
"tags": [],
|
|
967
|
+
"docs": "RSSI (Received Signal Strength Indicator).",
|
|
968
|
+
"complexTypes": [],
|
|
969
|
+
"type": "number"
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
"name": "proximity",
|
|
973
|
+
"tags": [],
|
|
974
|
+
"docs": "Proximity: 'immediate', 'near', 'far', or 'unknown'.",
|
|
975
|
+
"complexTypes": [],
|
|
976
|
+
"type": "'immediate' | 'near' | 'far' | 'unknown'"
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
"name": "accuracy",
|
|
980
|
+
"tags": [],
|
|
981
|
+
"docs": "Estimated distance in meters.",
|
|
982
|
+
"complexTypes": [],
|
|
983
|
+
"type": "number"
|
|
984
|
+
}
|
|
985
|
+
]
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
"name": "MonitoringEventData",
|
|
989
|
+
"slug": "monitoringeventdata",
|
|
990
|
+
"docs": "Event data when entering or exiting a region.",
|
|
991
|
+
"tags": [],
|
|
992
|
+
"methods": [],
|
|
993
|
+
"properties": [
|
|
994
|
+
{
|
|
995
|
+
"name": "region",
|
|
996
|
+
"tags": [],
|
|
997
|
+
"docs": "Region that triggered the event.",
|
|
998
|
+
"complexTypes": [
|
|
999
|
+
"BeaconRegion"
|
|
1000
|
+
],
|
|
1001
|
+
"type": "BeaconRegion"
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
"name": "state",
|
|
1005
|
+
"tags": [],
|
|
1006
|
+
"docs": "Event state: 'enter' or 'exit'.",
|
|
1007
|
+
"complexTypes": [],
|
|
1008
|
+
"type": "'enter' | 'exit'"
|
|
1009
|
+
}
|
|
1010
|
+
]
|
|
644
1011
|
}
|
|
645
1012
|
],
|
|
646
1013
|
"enums": [],
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { Plugin, PluginListenerHandle } from '@capacitor/core';
|
|
1
2
|
/**
|
|
2
3
|
* Capacitor iBeacon Plugin - Proximity detection and beacon region monitoring.
|
|
3
4
|
*
|
|
4
5
|
* @since 1.0.0
|
|
5
6
|
*/
|
|
6
|
-
export interface CapacitorIbeaconPlugin {
|
|
7
|
+
export interface CapacitorIbeaconPlugin extends Plugin {
|
|
7
8
|
/**
|
|
8
9
|
* Start monitoring for a beacon region. Triggers events when entering/exiting the region.
|
|
9
10
|
*
|
|
@@ -253,6 +254,101 @@ export interface CapacitorIbeaconPlugin {
|
|
|
253
254
|
* ```
|
|
254
255
|
*/
|
|
255
256
|
setBackgroundScanPeriod(options: BackgroundScanPeriodOptions): Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Listen for beacon ranging events.
|
|
259
|
+
*
|
|
260
|
+
* @param eventName - The event name ('didRangeBeacons')
|
|
261
|
+
* @param listenerFunc - Callback function that receives beacon data
|
|
262
|
+
* @returns Promise that resolves with a PluginListenerHandle
|
|
263
|
+
* @since 1.0.0
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* const listener = await CapacitorIbeacon.addListener('didRangeBeacons', (data) => {
|
|
267
|
+
* console.log('Beacons:', data.beacons);
|
|
268
|
+
* });
|
|
269
|
+
* // Remove listener when done
|
|
270
|
+
* await listener.remove();
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
addListener(eventName: 'didRangeBeacons', listenerFunc: (data: RangingEventData) => void): Promise<PluginListenerHandle>;
|
|
274
|
+
/**
|
|
275
|
+
* Listen for region enter events.
|
|
276
|
+
*
|
|
277
|
+
* @param eventName - The event name ('didEnterRegion')
|
|
278
|
+
* @param listenerFunc - Callback function that receives region data
|
|
279
|
+
* @returns Promise that resolves with a PluginListenerHandle
|
|
280
|
+
* @since 1.0.0
|
|
281
|
+
* @example
|
|
282
|
+
* ```typescript
|
|
283
|
+
* const listener = await CapacitorIbeacon.addListener('didEnterRegion', (data) => {
|
|
284
|
+
* console.log('Entered region:', data.region.identifier);
|
|
285
|
+
* });
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
addListener(eventName: 'didEnterRegion', listenerFunc: (data: {
|
|
289
|
+
region: BeaconRegion;
|
|
290
|
+
}) => void): Promise<PluginListenerHandle>;
|
|
291
|
+
/**
|
|
292
|
+
* Listen for region exit events.
|
|
293
|
+
*
|
|
294
|
+
* @param eventName - The event name ('didExitRegion')
|
|
295
|
+
* @param listenerFunc - Callback function that receives region data
|
|
296
|
+
* @returns Promise that resolves with a PluginListenerHandle
|
|
297
|
+
* @since 1.0.0
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* const listener = await CapacitorIbeacon.addListener('didExitRegion', (data) => {
|
|
301
|
+
* console.log('Exited region:', data.region.identifier);
|
|
302
|
+
* });
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
addListener(eventName: 'didExitRegion', listenerFunc: (data: {
|
|
306
|
+
region: BeaconRegion;
|
|
307
|
+
}) => void): Promise<PluginListenerHandle>;
|
|
308
|
+
/**
|
|
309
|
+
* Listen for region state determination events.
|
|
310
|
+
*
|
|
311
|
+
* @param eventName - The event name ('didDetermineStateForRegion')
|
|
312
|
+
* @param listenerFunc - Callback function that receives region and state data
|
|
313
|
+
* @returns Promise that resolves with a PluginListenerHandle
|
|
314
|
+
* @since 1.0.0
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* const listener = await CapacitorIbeacon.addListener('didDetermineStateForRegion', (data) => {
|
|
318
|
+
* console.log('Region state:', data.state, 'for', data.region.identifier);
|
|
319
|
+
* });
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
addListener(eventName: 'didDetermineStateForRegion', listenerFunc: (data: MonitoringEventData) => void): Promise<PluginListenerHandle>;
|
|
323
|
+
/**
|
|
324
|
+
* Listen for monitoring failure events.
|
|
325
|
+
*
|
|
326
|
+
* @param eventName - The event name ('monitoringDidFailForRegion')
|
|
327
|
+
* @param listenerFunc - Callback function that receives error data
|
|
328
|
+
* @returns Promise that resolves with a PluginListenerHandle
|
|
329
|
+
* @since 1.0.0
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* const listener = await CapacitorIbeacon.addListener('monitoringDidFailForRegion', (data) => {
|
|
333
|
+
* console.error('Monitoring failed:', data.error);
|
|
334
|
+
* });
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
addListener(eventName: 'monitoringDidFailForRegion', listenerFunc: (data: {
|
|
338
|
+
region: BeaconRegion;
|
|
339
|
+
error: string;
|
|
340
|
+
}) => void): Promise<PluginListenerHandle>;
|
|
341
|
+
/**
|
|
342
|
+
* Remove all listeners for this plugin.
|
|
343
|
+
*
|
|
344
|
+
* @returns Promise that resolves when all listeners are removed
|
|
345
|
+
* @since 1.0.0
|
|
346
|
+
* @example
|
|
347
|
+
* ```typescript
|
|
348
|
+
* await CapacitorIbeacon.removeAllListeners();
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
removeAllListeners(): Promise<void>;
|
|
256
352
|
}
|
|
257
353
|
/**
|
|
258
354
|
* Beacon region definition for monitoring and ranging.
|
|
@@ -374,35 +470,3 @@ export interface MonitoringEventData {
|
|
|
374
470
|
*/
|
|
375
471
|
state: 'enter' | 'exit';
|
|
376
472
|
}
|
|
377
|
-
/**
|
|
378
|
-
* Event listeners for iBeacon plugin.
|
|
379
|
-
*/
|
|
380
|
-
export interface BeaconEventListeners {
|
|
381
|
-
/**
|
|
382
|
-
* Called when beacons are detected during ranging.
|
|
383
|
-
*/
|
|
384
|
-
didRangeBeacons?: (data: RangingEventData) => void;
|
|
385
|
-
/**
|
|
386
|
-
* Called when entering or exiting a monitored region.
|
|
387
|
-
*/
|
|
388
|
-
didDetermineStateForRegion?: (data: MonitoringEventData) => void;
|
|
389
|
-
/**
|
|
390
|
-
* Called when entering a monitored region.
|
|
391
|
-
*/
|
|
392
|
-
didEnterRegion?: (data: {
|
|
393
|
-
region: BeaconRegion;
|
|
394
|
-
}) => void;
|
|
395
|
-
/**
|
|
396
|
-
* Called when exiting a monitored region.
|
|
397
|
-
*/
|
|
398
|
-
didExitRegion?: (data: {
|
|
399
|
-
region: BeaconRegion;
|
|
400
|
-
}) => void;
|
|
401
|
-
/**
|
|
402
|
-
* Called when monitoring state changes.
|
|
403
|
-
*/
|
|
404
|
-
monitoringDidFailForRegion?: (data: {
|
|
405
|
-
region: BeaconRegion;
|
|
406
|
-
error: string;
|
|
407
|
-
}) => void;
|
|
408
|
-
}
|
|
@@ -4,7 +4,7 @@ import CoreLocation
|
|
|
4
4
|
|
|
5
5
|
@objc(CapacitorIbeaconPlugin)
|
|
6
6
|
public class CapacitorIbeaconPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
7
|
-
private let pluginVersion: String = "8.1.
|
|
7
|
+
private let pluginVersion: String = "8.1.2"
|
|
8
8
|
public let identifier = "CapacitorIbeaconPlugin"
|
|
9
9
|
public let jsName = "CapacitorIbeacon"
|
|
10
10
|
public let pluginMethods: [CAPPluginMethod] = [
|
package/package.json
CHANGED