expo-beacon 0.3.2 → 0.4.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.
@@ -3,7 +3,9 @@ import { NativeModule, requireNativeModule } from "expo";
3
3
  import {
4
4
  ExpoBeaconModuleEvents,
5
5
  BeaconScanResult,
6
+ EddystoneScanResult,
6
7
  PairedBeacon,
8
+ PairedEddystone,
7
9
  NotificationConfig,
8
10
  MonitoringOptions,
9
11
  } from "./ExpoBeacon.types";
@@ -24,6 +26,16 @@ declare class ExpoBeaconModule extends NativeModule<ExpoBeaconModuleEvents> {
24
26
  scanDuration?: number,
25
27
  ): Promise<BeaconScanResult[]>;
26
28
 
29
+ /**
30
+ * Start a one-shot Eddystone beacon scan using BLE.
31
+ * Discovers Eddystone-UID and Eddystone-URL frames.
32
+ *
33
+ * @param scanDuration Duration in ms (default 5000)
34
+ */
35
+ scanForEddystonesAsync(
36
+ scanDuration?: number,
37
+ ): Promise<EddystoneScanResult[]>;
38
+
27
39
  /**
28
40
  * Register a beacon for persistent region monitoring.
29
41
  */
@@ -44,6 +56,25 @@ declare class ExpoBeaconModule extends NativeModule<ExpoBeaconModuleEvents> {
44
56
  */
45
57
  getPairedBeacons(): PairedBeacon[];
46
58
 
59
+ /**
60
+ * Register an Eddystone-UID beacon for persistent monitoring.
61
+ */
62
+ pairEddystone(
63
+ identifier: string,
64
+ namespace: string,
65
+ instance: string,
66
+ ): void;
67
+
68
+ /**
69
+ * Remove a previously paired Eddystone beacon.
70
+ */
71
+ unpairEddystone(identifier: string): void;
72
+
73
+ /**
74
+ * Return all currently paired Eddystone beacons.
75
+ */
76
+ getPairedEddystones(): PairedEddystone[];
77
+
47
78
  /**
48
79
  * Set persistent notification configuration. Settings are saved and applied to all
49
80
  * subsequent monitoring sessions until explicitly changed.
@@ -78,14 +109,4 @@ declare class ExpoBeaconModule extends NativeModule<ExpoBeaconModuleEvents> {
78
109
  requestPermissionsAsync(): Promise<boolean>;
79
110
  }
80
111
 
81
- try {
82
- // eslint-disable-next-line import/no-mutable-exports
83
- var module = requireNativeModule<ExpoBeaconModule>("ExpoBeacon");
84
- } catch {
85
- throw new Error(
86
- "expo-beacon: native module not found. Make sure you are using a development build " +
87
- "(not Expo Go) and have run `npx expo prebuild` followed by a native rebuild.",
88
- );
89
- }
90
-
91
- export default module;
112
+ export default requireNativeModule<ExpoBeaconModule>("ExpoBeacon");
@@ -1,7 +1,9 @@
1
1
  import type {
2
2
  ExpoBeaconModuleEvents,
3
3
  BeaconScanResult,
4
+ EddystoneScanResult,
4
5
  PairedBeacon,
6
+ PairedEddystone,
5
7
  } from "./ExpoBeacon.types";
6
8
 
7
9
  const notSupported = (): never => {
@@ -13,6 +15,9 @@ const stub = {
13
15
  _uuids: string[],
14
16
  _scanDuration?: number,
15
17
  ): Promise<BeaconScanResult[]> => notSupported(),
18
+ scanForEddystonesAsync: (
19
+ _scanDuration?: number,
20
+ ): Promise<EddystoneScanResult[]> => notSupported(),
16
21
  pairBeacon: (
17
22
  _identifier: string,
18
23
  _uuid: string,
@@ -21,6 +26,13 @@ const stub = {
21
26
  ): void => notSupported(),
22
27
  unpairBeacon: (_identifier: string): void => notSupported(),
23
28
  getPairedBeacons: (): PairedBeacon[] => notSupported(),
29
+ pairEddystone: (
30
+ _identifier: string,
31
+ _namespace: string,
32
+ _instance: string,
33
+ ): void => notSupported(),
34
+ unpairEddystone: (_identifier: string): void => notSupported(),
35
+ getPairedEddystones: (): PairedEddystone[] => notSupported(),
24
36
  startMonitoring: (): Promise<void> => notSupported(),
25
37
  stopMonitoring: (): Promise<void> => notSupported(),
26
38
  requestPermissionsAsync: (): Promise<boolean> => notSupported(),
package/src/index.ts CHANGED
@@ -13,4 +13,9 @@ export type {
13
13
  BeaconNotificationConfig,
14
14
  ForegroundServiceConfig,
15
15
  NotificationChannelConfig,
16
+ EddystoneFrameType,
17
+ EddystoneScanResult,
18
+ PairedEddystone,
19
+ EddystoneRegionEvent,
20
+ EddystoneDistanceEvent,
16
21
  } from "./ExpoBeacon.types";