react-native-ble-manager 11.5.6 → 12.0.0-rc.0

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.
Files changed (44) hide show
  1. package/README.md +16 -3
  2. package/RNBleManager.podspec +24 -0
  3. package/android/build.gradle +116 -43
  4. package/android/gradle.properties +1 -0
  5. package/android/src/main/java/it/innove/BleManager.java +174 -148
  6. package/android/src/main/java/it/innove/BleManagerPackage.java +15 -14
  7. package/android/src/main/java/it/innove/CompanionScanner.java +39 -13
  8. package/android/src/main/java/it/innove/DefaultPeripheral.java +4 -4
  9. package/android/src/main/java/it/innove/DefaultScanManager.java +16 -16
  10. package/android/src/main/java/it/innove/Peripheral.java +20 -17
  11. package/dist/cjs/NativeBleManager.d.ts +241 -0
  12. package/dist/cjs/NativeBleManager.js +5 -0
  13. package/dist/cjs/NativeBleManager.js.map +1 -0
  14. package/dist/cjs/index.d.ts +15 -3
  15. package/dist/cjs/index.js +89 -38
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/types.d.ts +17 -11
  18. package/dist/cjs/types.js +8 -8
  19. package/dist/cjs/types.js.map +1 -1
  20. package/dist/esm/NativeBleManager.d.ts +241 -0
  21. package/dist/esm/NativeBleManager.js +3 -0
  22. package/dist/esm/NativeBleManager.js.map +1 -0
  23. package/dist/esm/index.d.ts +15 -3
  24. package/dist/esm/index.js +92 -41
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/types.d.ts +17 -11
  27. package/ios/BleManager-Bridging-Header.h +7 -1
  28. package/ios/BleManager.h +39 -2
  29. package/ios/BleManager.mm +277 -0
  30. package/ios/Helper.swift +6 -6
  31. package/ios/RNBleManager.h +7 -0
  32. package/ios/{BleManager.swift → SwiftBleManager.swift} +322 -355
  33. package/package.json +107 -56
  34. package/src/NativeBleManager.ts +409 -0
  35. package/src/index.ts +162 -77
  36. package/src/types.ts +38 -31
  37. package/android/src/main/java/it/innove/LegacyScanManager.java +0 -112
  38. package/ios/BleManager.m +0 -153
  39. package/ios/BleManager.xcodeproj/project.pbxproj +0 -324
  40. package/ios/BleManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  41. package/ios/BleManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  42. package/ios/BleManager.xcodeproj/project.xcworkspace/xcuserdata/marco.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  43. package/ios/BleManager.xcodeproj/xcuserdata/marco.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  44. package/react-native-ble-manager.podspec +0 -17
package/src/index.ts CHANGED
@@ -1,4 +1,8 @@
1
- import { NativeEventEmitter, NativeModules } from "react-native";
1
+ import {
2
+ EventSubscription,
3
+ NativeEventEmitter,
4
+ NativeModules,
5
+ } from 'react-native';
2
6
  import {
3
7
  BleScanCallbackType,
4
8
  BleScanMatchCount,
@@ -12,15 +16,29 @@ import {
12
16
  PeripheralInfo,
13
17
  ScanOptions,
14
18
  StartOptions,
15
- } from "./types";
16
-
17
- export * from "./types";
18
-
19
- let bleManager = NativeModules.BleManager;
19
+ } from './types';
20
+ export * from './types';
21
+
22
+ // @ts-expect-error This applies the turbo module version only when turbo is enabled for backwards compatibility.
23
+ const isTurboModuleEnabled = global?.__turboModuleProxy != null;
24
+ if (isTurboModuleEnabled) {
25
+ // Warn users that this is a release candidate and should be used with caution.
26
+ console.warn(`
27
+ You're using a turbo module version of react-native-version!\n
28
+ If something is broken please feedback on "issues" https://github.com/innoveit/react-native-ble-manager\n
29
+ Please use with caution cause it's not quite stable yet.
30
+ `);
31
+ }
32
+ const BleManagerModule = isTurboModuleEnabled
33
+ ? require('./NativeBleManager').default
34
+ : NativeModules.BleManager;
20
35
 
21
36
  class BleManager extends NativeEventEmitter {
22
37
  constructor() {
23
- super(bleManager);
38
+ if (!BleManagerModule) {
39
+ throw new Error('BleManagerModule not found');
40
+ }
41
+ super(BleManagerModule);
24
42
  this.isPeripheralConnected = this.isPeripheralConnected.bind(this);
25
43
  }
26
44
 
@@ -33,7 +51,7 @@ class BleManager extends NativeEventEmitter {
33
51
  */
34
52
  read(peripheralId: string, serviceUUID: string, characteristicUUID: string) {
35
53
  return new Promise<number[]>((fulfill, reject) => {
36
- bleManager.read(
54
+ BleManagerModule.read(
37
55
  peripheralId,
38
56
  serviceUUID,
39
57
  characteristicUUID,
@@ -63,7 +81,7 @@ class BleManager extends NativeEventEmitter {
63
81
  descriptorUUID: string
64
82
  ) {
65
83
  return new Promise<number[]>((fulfill, reject) => {
66
- bleManager.readDescriptor(
84
+ BleManagerModule.readDescriptor(
67
85
  peripheralId,
68
86
  serviceUUID,
69
87
  characteristicUUID,
@@ -96,7 +114,7 @@ class BleManager extends NativeEventEmitter {
96
114
  data: number[]
97
115
  ) {
98
116
  return new Promise<void>((fulfill, reject) => {
99
- bleManager.writeDescriptor(
117
+ BleManagerModule.writeDescriptor(
100
118
  peripheralId,
101
119
  serviceUUID,
102
120
  characteristicUUID,
@@ -120,7 +138,7 @@ class BleManager extends NativeEventEmitter {
120
138
  */
121
139
  readRSSI(peripheralId: string) {
122
140
  return new Promise<number>((fulfill, reject) => {
123
- bleManager.readRSSI(
141
+ BleManagerModule.readRSSI(
124
142
  peripheralId,
125
143
  (error: string | null, rssi: number) => {
126
144
  if (error) {
@@ -140,7 +158,7 @@ class BleManager extends NativeEventEmitter {
140
158
  */
141
159
  refreshCache(peripheralId: string) {
142
160
  return new Promise<boolean>((fulfill, reject) => {
143
- bleManager.refreshCache(
161
+ BleManagerModule.refreshCache(
144
162
  peripheralId,
145
163
  (error: string | null, result: boolean) => {
146
164
  if (error) {
@@ -161,7 +179,7 @@ class BleManager extends NativeEventEmitter {
161
179
  */
162
180
  retrieveServices(peripheralId: string, serviceUUIDs: string[] = []) {
163
181
  return new Promise<PeripheralInfo>((fulfill, reject) => {
164
- bleManager.retrieveServices(
182
+ BleManagerModule.retrieveServices(
165
183
  peripheralId,
166
184
  serviceUUIDs,
167
185
  (error: string | null, peripheral: PeripheralInfo) => {
@@ -192,7 +210,7 @@ class BleManager extends NativeEventEmitter {
192
210
  maxByteSize: number = 20
193
211
  ) {
194
212
  return new Promise<void>((fulfill, reject) => {
195
- bleManager.write(
213
+ BleManagerModule.write(
196
214
  peripheralId,
197
215
  serviceUUID,
198
216
  characteristicUUID,
@@ -228,7 +246,7 @@ class BleManager extends NativeEventEmitter {
228
246
  queueSleepTime: number = 10
229
247
  ) {
230
248
  return new Promise<void>((fulfill, reject) => {
231
- bleManager.writeWithoutResponse(
249
+ BleManagerModule.writeWithoutResponse(
232
250
  peripheralId,
233
251
  serviceUUID,
234
252
  characteristicUUID,
@@ -251,13 +269,17 @@ class BleManager extends NativeEventEmitter {
251
269
  if (!options) {
252
270
  options = {};
253
271
  }
254
- bleManager.connect(peripheralId, options, (error: string | null) => {
255
- if (error) {
256
- reject(error);
257
- } else {
258
- fulfill();
272
+ BleManagerModule.connect(
273
+ peripheralId,
274
+ options,
275
+ (error: string | null) => {
276
+ if (error) {
277
+ reject(error);
278
+ } else {
279
+ fulfill();
280
+ }
259
281
  }
260
- });
282
+ );
261
283
  });
262
284
  }
263
285
 
@@ -269,7 +291,7 @@ class BleManager extends NativeEventEmitter {
269
291
  */
270
292
  createBond(peripheralId: string, peripheralPin: string | null = null) {
271
293
  return new Promise<void>((fulfill, reject) => {
272
- bleManager.createBond(
294
+ BleManagerModule.createBond(
273
295
  peripheralId,
274
296
  peripheralPin,
275
297
  (error: string | null) => {
@@ -290,7 +312,7 @@ class BleManager extends NativeEventEmitter {
290
312
  */
291
313
  removeBond(peripheralId: string) {
292
314
  return new Promise<void>((fulfill, reject) => {
293
- bleManager.removeBond(peripheralId, (error: string | null) => {
315
+ BleManagerModule.removeBond(peripheralId, (error: string | null) => {
294
316
  if (error) {
295
317
  reject(error);
296
318
  } else {
@@ -308,13 +330,17 @@ class BleManager extends NativeEventEmitter {
308
330
  */
309
331
  disconnect(peripheralId: string, force: boolean = true) {
310
332
  return new Promise<void>((fulfill, reject) => {
311
- bleManager.disconnect(peripheralId, force, (error: string | null) => {
312
- if (error) {
313
- reject(error);
314
- } else {
315
- fulfill();
333
+ BleManagerModule.disconnect(
334
+ peripheralId,
335
+ force,
336
+ (error: string | null) => {
337
+ if (error) {
338
+ reject(error);
339
+ } else {
340
+ fulfill();
341
+ }
316
342
  }
317
- });
343
+ );
318
344
  });
319
345
  }
320
346
 
@@ -324,7 +350,7 @@ class BleManager extends NativeEventEmitter {
324
350
  characteristicUUID: string
325
351
  ) {
326
352
  return new Promise<void>((fulfill, reject) => {
327
- bleManager.startNotification(
353
+ BleManagerModule.startNotification(
328
354
  peripheralId,
329
355
  serviceUUID,
330
356
  characteristicUUID,
@@ -354,7 +380,7 @@ class BleManager extends NativeEventEmitter {
354
380
  buffer: number
355
381
  ) {
356
382
  return new Promise<void>((fulfill, reject) => {
357
- bleManager.startNotificationUseBuffer(
383
+ BleManagerModule.startNotificationUseBuffer(
358
384
  peripheralId,
359
385
  serviceUUID,
360
386
  characteristicUUID,
@@ -376,7 +402,7 @@ class BleManager extends NativeEventEmitter {
376
402
  characteristicUUID: string
377
403
  ) {
378
404
  return new Promise<void>((fulfill, reject) => {
379
- bleManager.stopNotification(
405
+ BleManagerModule.stopNotification(
380
406
  peripheralId,
381
407
  serviceUUID,
382
408
  characteristicUUID,
@@ -393,7 +419,7 @@ class BleManager extends NativeEventEmitter {
393
419
 
394
420
  checkState() {
395
421
  return new Promise<BleState>((fulfill, _) => {
396
- bleManager.checkState((state: BleState) => {
422
+ BleManagerModule.checkState((state: BleState) => {
397
423
  fulfill(state);
398
424
  });
399
425
  });
@@ -404,7 +430,7 @@ class BleManager extends NativeEventEmitter {
404
430
  if (options == null) {
405
431
  options = {};
406
432
  }
407
- bleManager.start(options, (error: string | null) => {
433
+ BleManagerModule.start(options, (error: string | null) => {
408
434
  if (error) {
409
435
  reject(error);
410
436
  } else {
@@ -467,14 +493,14 @@ class BleManager extends NativeEventEmitter {
467
493
  if (!scanningOptions.exactAdvertisingName) {
468
494
  delete scanningOptions.exactAdvertisingName;
469
495
  } else {
470
- if (typeof scanningOptions.exactAdvertisingName === "string") {
496
+ if (typeof scanningOptions.exactAdvertisingName === 'string') {
471
497
  scanningOptions.exactAdvertisingName = [
472
498
  scanningOptions.exactAdvertisingName,
473
499
  ];
474
500
  }
475
501
  }
476
502
 
477
- bleManager.scan(
503
+ BleManagerModule.scan(
478
504
  serviceUUIDs,
479
505
  seconds,
480
506
  allowDuplicates,
@@ -492,7 +518,7 @@ class BleManager extends NativeEventEmitter {
492
518
 
493
519
  stopScan() {
494
520
  return new Promise<void>((fulfill, reject) => {
495
- bleManager.stopScan((error: string | null) => {
521
+ BleManagerModule.stopScan((error: string | null) => {
496
522
  if (error) {
497
523
  reject(error);
498
524
  } else {
@@ -508,7 +534,7 @@ class BleManager extends NativeEventEmitter {
508
534
  */
509
535
  enableBluetooth() {
510
536
  return new Promise<void>((fulfill, reject) => {
511
- bleManager.enableBluetooth((error: string | null) => {
537
+ BleManagerModule.enableBluetooth((error: string | null) => {
512
538
  if (error) {
513
539
  reject(error);
514
540
  } else {
@@ -525,7 +551,7 @@ class BleManager extends NativeEventEmitter {
525
551
  */
526
552
  getConnectedPeripherals(serviceUUIDs: string[] = []) {
527
553
  return new Promise<Peripheral[]>((fulfill, reject) => {
528
- bleManager.getConnectedPeripherals(
554
+ BleManagerModule.getConnectedPeripherals(
529
555
  serviceUUIDs,
530
556
  (error: string | null, result: Peripheral[] | null) => {
531
557
  if (error) {
@@ -548,7 +574,7 @@ class BleManager extends NativeEventEmitter {
548
574
  */
549
575
  getBondedPeripherals() {
550
576
  return new Promise<Peripheral[]>((fulfill, reject) => {
551
- bleManager.getBondedPeripherals(
577
+ BleManagerModule.getBondedPeripherals(
552
578
  (error: string | null, result: Peripheral[] | null) => {
553
579
  if (error) {
554
580
  reject(error);
@@ -566,7 +592,7 @@ class BleManager extends NativeEventEmitter {
566
592
 
567
593
  getDiscoveredPeripherals() {
568
594
  return new Promise<Peripheral[]>((fulfill, reject) => {
569
- bleManager.getDiscoveredPeripherals(
595
+ BleManagerModule.getDiscoveredPeripherals(
570
596
  (error: string | null, result: Peripheral[] | null) => {
571
597
  if (error) {
572
598
  reject(error);
@@ -589,13 +615,16 @@ class BleManager extends NativeEventEmitter {
589
615
  */
590
616
  removePeripheral(peripheralId: string) {
591
617
  return new Promise<void>((fulfill, reject) => {
592
- bleManager.removePeripheral(peripheralId, (error: string | null) => {
593
- if (error) {
594
- reject(error);
595
- } else {
596
- fulfill();
618
+ BleManagerModule.removePeripheral(
619
+ peripheralId,
620
+ (error: string | null) => {
621
+ if (error) {
622
+ reject(error);
623
+ } else {
624
+ fulfill();
625
+ }
597
626
  }
598
- });
627
+ );
599
628
  });
600
629
  }
601
630
 
@@ -621,7 +650,7 @@ class BleManager extends NativeEventEmitter {
621
650
  */
622
651
  isScanning() {
623
652
  return new Promise<boolean>((fulfill, reject) => {
624
- bleManager.isScanning((error: string | null, status: boolean) => {
653
+ BleManagerModule.isScanning((error: string | null, status: boolean) => {
625
654
  if (error) {
626
655
  reject(error);
627
656
  } else {
@@ -642,7 +671,7 @@ class BleManager extends NativeEventEmitter {
642
671
  connectionPriority: ConnectionPriority
643
672
  ) {
644
673
  return new Promise<boolean>((fulfill, reject) => {
645
- bleManager.requestConnectionPriority(
674
+ BleManagerModule.requestConnectionPriority(
646
675
  peripheralId,
647
676
  connectionPriority,
648
677
  (error: string | null, status: boolean) => {
@@ -664,7 +693,7 @@ class BleManager extends NativeEventEmitter {
664
693
  */
665
694
  requestMTU(peripheralId: string, mtu: number) {
666
695
  return new Promise<number>((fulfill, reject) => {
667
- bleManager.requestMTU(
696
+ BleManagerModule.requestMTU(
668
697
  peripheralId,
669
698
  mtu,
670
699
  (error: string | null, mtu: number) => {
@@ -685,13 +714,15 @@ class BleManager extends NativeEventEmitter {
685
714
  */
686
715
  getAssociatedPeripherals() {
687
716
  return new Promise<Peripheral[]>((fulfill, reject) => {
688
- bleManager.getAssociatedPeripherals((error: string | null, peripherals: Peripheral[] | null) => {
689
- if (error) {
690
- reject(error);
691
- } else {
692
- fulfill(peripherals || []);
717
+ BleManagerModule.getAssociatedPeripherals(
718
+ (error: string | null, peripherals: Peripheral[] | null) => {
719
+ if (error) {
720
+ reject(error);
721
+ } else {
722
+ fulfill(peripherals || []);
723
+ }
693
724
  }
694
- });
725
+ );
695
726
  });
696
727
  }
697
728
 
@@ -703,13 +734,16 @@ class BleManager extends NativeEventEmitter {
703
734
  */
704
735
  removeAssociatedPeripheral(peripheralId: string) {
705
736
  return new Promise<void>((fulfill, reject) => {
706
- bleManager.removeAssociatedPeripheral(peripheralId, (error: string | null) => {
707
- if (error !== null) {
708
- reject(error);
709
- } else {
710
- fulfill();
737
+ BleManagerModule.removeAssociatedPeripheral(
738
+ peripheralId,
739
+ (error: string | null) => {
740
+ if (error !== null) {
741
+ reject(error);
742
+ } else {
743
+ fulfill();
744
+ }
711
745
  }
712
- });
746
+ );
713
747
  });
714
748
  }
715
749
 
@@ -721,8 +755,10 @@ class BleManager extends NativeEventEmitter {
721
755
  * @return Promise resolving to a boolean.
722
756
  */
723
757
  supportsCompanion() {
724
- return new Promise<boolean>(fulfill => {
725
- bleManager.supportsCompanion((supports: boolean) => fulfill(supports));
758
+ return new Promise<boolean>((fulfill) => {
759
+ BleManagerModule.supportsCompanion((supports: boolean) =>
760
+ fulfill(supports)
761
+ );
726
762
  });
727
763
  }
728
764
 
@@ -731,18 +767,19 @@ class BleManager extends NativeEventEmitter {
731
767
  *
732
768
  * Start companion scan.
733
769
  */
734
- companionScan(
735
- serviceUUIDs: string[],
736
- options: CompanionScanOptions = {}
737
- ) {
770
+ companionScan(serviceUUIDs: string[], options: CompanionScanOptions = {}) {
738
771
  return new Promise<Peripheral | null>((fulfill, reject) => {
739
- bleManager.companionScan(serviceUUIDs, options, (error: string | null, peripheral: Peripheral | null) => {
740
- if (error) {
741
- reject(error)
742
- } else {
743
- fulfill(peripheral);
772
+ BleManagerModule.companionScan(
773
+ serviceUUIDs,
774
+ options,
775
+ (error: string | null, peripheral: Peripheral | null) => {
776
+ if (error) {
777
+ reject(error);
778
+ } else {
779
+ fulfill(peripheral);
780
+ }
744
781
  }
745
- });
782
+ );
746
783
  });
747
784
  }
748
785
 
@@ -751,7 +788,7 @@ class BleManager extends NativeEventEmitter {
751
788
  * @param name
752
789
  */
753
790
  setName(name: string) {
754
- bleManager.setName(name);
791
+ BleManagerModule.setName(name);
755
792
  }
756
793
 
757
794
  /**
@@ -761,7 +798,7 @@ class BleManager extends NativeEventEmitter {
761
798
  */
762
799
  getMaximumWriteValueLengthForWithoutResponse(peripheralId: string) {
763
800
  return new Promise<number>((fulfill, reject) => {
764
- bleManager.getMaximumWriteValueLengthForWithoutResponse(
801
+ BleManagerModule.getMaximumWriteValueLengthForWithoutResponse(
765
802
  peripheralId,
766
803
  (error: string | null, max: number) => {
767
804
  if (error) {
@@ -781,7 +818,7 @@ class BleManager extends NativeEventEmitter {
781
818
  */
782
819
  getMaximumWriteValueLengthForWithResponse(peripheralId: string) {
783
820
  return new Promise<number>((fulfill, reject) => {
784
- bleManager.getMaximumWriteValueLengthForWithResponse(
821
+ BleManagerModule.getMaximumWriteValueLengthForWithResponse(
785
822
  peripheralId,
786
823
  (error: string | null, max: number) => {
787
824
  if (error) {
@@ -793,6 +830,54 @@ class BleManager extends NativeEventEmitter {
793
830
  );
794
831
  });
795
832
  }
833
+
834
+ onDiscoverPeripheral(callback: any): EventSubscription {
835
+ return BleManagerModule.onDiscoverPeripheral(callback);
836
+ }
837
+
838
+ onStopScan(callback: any): EventSubscription {
839
+ return BleManagerModule.onStopScan(callback);
840
+ }
841
+
842
+ onDidUpdateState(callback: any): EventSubscription {
843
+ return BleManagerModule.onStateChange(callback);
844
+ }
845
+
846
+ onCentralManagerDidUpdateState(callback: any): EventSubscription {
847
+ return BleManagerModule.onCentralManagerDidUpdateState(callback);
848
+ }
849
+
850
+ onConnectPeripheral(callback: any): EventSubscription {
851
+ return BleManagerModule.onConnectPeripheral(callback);
852
+ }
853
+
854
+ onDisconnectPeripheral(callback: any): EventSubscription {
855
+ return BleManagerModule.onDisconnectPeripheral(callback);
856
+ }
857
+
858
+ onDidUpdateValueForCharacteristic(callback: any): EventSubscription {
859
+ return BleManagerModule.onDidUpdateValueForCharacteristic(callback);
860
+ }
861
+
862
+ onPeripheralDidBond(callback: any): EventSubscription {
863
+ return BleManagerModule.onPeripheralDidBond(callback);
864
+ }
865
+
866
+ onCentralManagerWillRestoreState(callback: any): EventSubscription {
867
+ return BleManagerModule.onCentralManagerWillRestoreState(callback);
868
+ }
869
+
870
+ onDidUpdateNotificationStateFor(callback: any): EventSubscription {
871
+ return BleManagerModule.onDidUpdateNotificationStateFor(callback);
872
+ }
873
+
874
+ onCompanionPeripheral(callback: any): EventSubscription {
875
+ return BleManagerModule.onCompanionPeripheral(callback);
876
+ }
877
+
878
+ onCompanionAvailability(callback: any): EventSubscription {
879
+ return BleManagerModule.onCompanionAvailability(callback);
880
+ }
796
881
  }
797
882
 
798
883
  export default new BleManager();
package/src/types.ts CHANGED
@@ -6,26 +6,26 @@ export enum BleState {
6
6
  /**
7
7
  * [iOS only]
8
8
  */
9
- Unknown = "unknown",
9
+ Unknown = 'unknown',
10
10
  /**
11
11
  * [iOS only]
12
12
  */
13
- Resetting = "resetting",
14
- Unsupported = "unsupported",
13
+ Resetting = 'resetting',
14
+ Unsupported = 'unsupported',
15
15
  /**
16
16
  * [iOS only]
17
17
  */
18
- Unauthorized = "unauthorized",
19
- On = "on",
20
- Off = "off",
18
+ Unauthorized = 'unauthorized',
19
+ On = 'on',
20
+ Off = 'off',
21
21
  /**
22
22
  * [android only]
23
23
  */
24
- TurningOn = "turning_on",
24
+ TurningOn = 'turning_on',
25
25
  /**
26
26
  * [android only]
27
27
  */
28
- TurningOff = "turning_off",
28
+ TurningOff = 'turning_off',
29
29
  }
30
30
 
31
31
  export interface Peripheral {
@@ -47,7 +47,7 @@ export interface AdvertisingData {
47
47
  }
48
48
 
49
49
  export interface CustomAdvertisingData {
50
- CDVType: "ArrayBuffer";
50
+ CDVType: 'ArrayBuffer';
51
51
  /**
52
52
  * data as an array of numbers (which can be converted back to a Uint8Array (ByteArray),
53
53
  * using something like [Buffer.from()](https://github.com/feross/buffer))
@@ -138,7 +138,7 @@ export interface ScanOptions {
138
138
  * if `callbackType` is set to `FirstMatch`, the shortenedLocalName will be used for filtering.
139
139
  * https://developer.android.com/reference/android/bluetooth/le/ScanFilter.Builder#setDeviceName(java.lang.String)
140
140
  */
141
- exactAdvertisingName?: string|string[];
141
+ exactAdvertisingName?: string | string[];
142
142
  /**
143
143
  * Android only. Filters scan results by manufacturer id and data.
144
144
  * `manufacturerId` usually matches the company id, can be given as a hex, e.g. 0xe4f7.
@@ -150,7 +150,7 @@ export interface ScanOptions {
150
150
  manufacturerId: number;
151
151
  manufacturerData?: number[];
152
152
  manufacturerDataMask?: number[];
153
- }
153
+ };
154
154
  /**
155
155
  * When using compaion mode, only associate single peripheral.
156
156
  *
@@ -236,16 +236,16 @@ export interface Characteristic {
236
236
  * See https://developer.apple.com/documentation/corebluetooth/cbcharacteristicproperties
237
237
  */
238
238
  properties: {
239
- Broadcast?: "Broadcast";
240
- Read?: "Read";
241
- WriteWithoutResponse?: "WriteWithoutResponse";
242
- Write?: "Write";
243
- Notify?: "Notify";
244
- Indicate?: "Indicate";
245
- AuthenticatedSignedWrites?: "AuthenticatedSignedWrites";
246
- ExtendedProperties?: "ExtendedProperties";
247
- NotifyEncryptionRequired?: "NotifyEncryptionRequired";
248
- IndicateEncryptionRequired?: "IndicateEncryptionRequired";
239
+ Broadcast?: 'Broadcast';
240
+ Read?: 'Read';
241
+ WriteWithoutResponse?: 'WriteWithoutResponse';
242
+ Write?: 'Write';
243
+ Notify?: 'Notify';
244
+ Indicate?: 'Indicate';
245
+ AuthenticatedSignedWrites?: 'AuthenticatedSignedWrites';
246
+ ExtendedProperties?: 'ExtendedProperties';
247
+ NotifyEncryptionRequired?: 'NotifyEncryptionRequired';
248
+ IndicateEncryptionRequired?: 'IndicateEncryptionRequired';
249
249
  };
250
250
  characteristic: string;
251
251
  service: string;
@@ -259,24 +259,24 @@ export interface PeripheralInfo extends Peripheral {
259
259
  }
260
260
 
261
261
  export enum BleEventType {
262
- BleManagerDidUpdateState = "BleManagerDidUpdateState",
263
- BleManagerStopScan = "BleManagerStopScan",
264
- BleManagerDiscoverPeripheral = "BleManagerDiscoverPeripheral",
265
- BleManagerDidUpdateValueForCharacteristic = "BleManagerDidUpdateValueForCharacteristic",
266
- BleManagerConnectPeripheral = "BleManagerConnectPeripheral",
267
- BleManagerDisconnectPeripheral = "BleManagerDisconnectPeripheral",
262
+ BleManagerDidUpdateState = 'BleManagerDidUpdateState',
263
+ BleManagerStopScan = 'BleManagerStopScan',
264
+ BleManagerDiscoverPeripheral = 'BleManagerDiscoverPeripheral',
265
+ BleManagerDidUpdateValueForCharacteristic = 'BleManagerDidUpdateValueForCharacteristic',
266
+ BleManagerConnectPeripheral = 'BleManagerConnectPeripheral',
267
+ BleManagerDisconnectPeripheral = 'BleManagerDisconnectPeripheral',
268
268
  /**
269
269
  * [Android only]
270
270
  */
271
- BleManagerPeripheralDidBond = "BleManagerPeripheralDidBond",
271
+ BleManagerPeripheralDidBond = 'BleManagerPeripheralDidBond',
272
272
  /**
273
273
  * [iOS only]
274
274
  */
275
- BleManagerCentralManagerWillRestoreState = "BleManagerCentralManagerWillRestoreState",
275
+ BleManagerCentralManagerWillRestoreState = 'BleManagerCentralManagerWillRestoreState',
276
276
  /**
277
277
  * [iOS only]
278
278
  */
279
- BleManagerDidUpdateNotificationStateFor = "BleManagerDidUpdateNotificationStateFor",
279
+ BleManagerDidUpdateNotificationStateFor = 'BleManagerDidUpdateNotificationStateFor',
280
280
  }
281
281
 
282
282
  export interface BleStopScanEvent {
@@ -373,13 +373,20 @@ export interface BleManagerDidUpdateNotificationStateForEvent {
373
373
  readonly code: number;
374
374
  }
375
375
 
376
+ /**
377
+ * [iOS only]
378
+ */
379
+ export interface BleManagerCentralManagerWillRestoreState {
380
+ peripherals: Peripheral[];
381
+ }
382
+
376
383
  /**
377
384
  * [Android only]
378
385
  *
379
386
  * Associate callback received a failure or failed to start the intent to
380
387
  * pick the device to associate.
381
388
  */
382
- export type BleManagerCompanionFailure = { error: string; };
389
+ export type BleManagerCompanionFailure = { error: string };
383
390
 
384
391
  /**
385
392
  * [Android only]