expo-beacon 0.3.1 → 0.3.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.
|
@@ -1,2 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
import { NativeModule } from "expo";
|
|
2
|
+
import { ExpoBeaconModuleEvents, BeaconScanResult, PairedBeacon, NotificationConfig, MonitoringOptions } from "./ExpoBeacon.types";
|
|
3
|
+
declare class ExpoBeaconModule extends NativeModule<ExpoBeaconModuleEvents> {
|
|
4
|
+
/**
|
|
5
|
+
* Start a one-shot iBeacon scan. Resolves with discovered beacons after scanDuration ms.
|
|
6
|
+
*
|
|
7
|
+
* Pass one or more UUIDs to scan for specific beacons (uses CoreLocation on iOS).
|
|
8
|
+
* Pass an empty array or omit to perform a wildcard scan that discovers all nearby
|
|
9
|
+
* iBeacons (uses CoreBluetooth on iOS — foreground only).
|
|
10
|
+
*
|
|
11
|
+
* @param uuids Proximity UUIDs to filter by. Empty/omitted = wildcard scan.
|
|
12
|
+
* @param scanDuration Duration in ms (default 5000)
|
|
13
|
+
*/
|
|
14
|
+
scanForBeaconsAsync(uuids?: string[], scanDuration?: number): Promise<BeaconScanResult[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Register a beacon for persistent region monitoring.
|
|
17
|
+
*/
|
|
18
|
+
pairBeacon(identifier: string, uuid: string, major: number, minor: number): void;
|
|
19
|
+
/**
|
|
20
|
+
* Remove a previously paired beacon.
|
|
21
|
+
*/
|
|
22
|
+
unpairBeacon(identifier: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Return all currently paired beacons.
|
|
25
|
+
*/
|
|
26
|
+
getPairedBeacons(): PairedBeacon[];
|
|
27
|
+
/**
|
|
28
|
+
* Set persistent notification configuration. Settings are saved and applied to all
|
|
29
|
+
* subsequent monitoring sessions until explicitly changed.
|
|
30
|
+
*/
|
|
31
|
+
setNotificationConfig(config: NotificationConfig): void;
|
|
32
|
+
/**
|
|
33
|
+
* Start background region monitoring for all paired beacons.
|
|
34
|
+
* On Android starts a foreground service.
|
|
35
|
+
* On iOS starts CLLocationManager region monitoring.
|
|
36
|
+
*
|
|
37
|
+
* Accepts a plain number (backward-compatible maxDistance shorthand) or a
|
|
38
|
+
* MonitoringOptions object with maxDistance and/or notification overrides.
|
|
39
|
+
*/
|
|
40
|
+
startMonitoring(options?: MonitoringOptions | number): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Stop background region monitoring.
|
|
43
|
+
*/
|
|
44
|
+
stopMonitoring(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Start a continuous BLE scan. Fires `onBeaconFound` events as beacons are detected.
|
|
47
|
+
* Call stopContinuousScan() to end the scan.
|
|
48
|
+
*/
|
|
49
|
+
startContinuousScan(): void;
|
|
50
|
+
/** Stop the continuous scan started by startContinuousScan(). */
|
|
51
|
+
stopContinuousScan(): void;
|
|
52
|
+
/** Request Bluetooth + Location permissions. Returns true if granted. */
|
|
53
|
+
requestPermissionsAsync(): Promise<boolean>;
|
|
54
|
+
}
|
|
55
|
+
declare const _default: ExpoBeaconModule;
|
|
56
|
+
export default _default;
|
|
2
57
|
//# sourceMappingURL=ExpoBeaconModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoBeaconModule.d.ts","sourceRoot":"","sources":["../src/ExpoBeaconModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoBeaconModule.d.ts","sourceRoot":"","sources":["../src/ExpoBeaconModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,OAAO,gBAAiB,SAAQ,YAAY,CAAC,sBAAsB,CAAC;IACzE;;;;;;;;;OASG;IACH,mBAAmB,CACjB,KAAK,CAAC,EAAE,MAAM,EAAE,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAE9B;;OAEG;IACH,UAAU,CACR,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI;IAEP;;OAEG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAEtC;;OAEG;IACH,gBAAgB,IAAI,YAAY,EAAE;IAElC;;;OAGG;IACH,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAEvD;;;;;;;OAOG;IACH,eAAe,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEpE;;OAEG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAE/B;;;OAGG;IACH,mBAAmB,IAAI,IAAI;IAE3B,iEAAiE;IACjE,kBAAkB,IAAI,IAAI;IAE1B,yEAAyE;IACzE,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;CAC5C;;AAED,wBAAmE"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
import { requireNativeModule } from "expo";
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line import/no-mutable-exports
|
|
4
|
-
var module = requireNativeModule("ExpoBeacon");
|
|
5
|
-
}
|
|
6
|
-
catch {
|
|
7
|
-
throw new Error("expo-beacon: native module not found. Make sure you are using a development build " +
|
|
8
|
-
"(not Expo Go) and have run `npx expo prebuild` followed by a native rebuild.");
|
|
9
|
-
}
|
|
10
|
-
export default module;
|
|
2
|
+
export default requireNativeModule("ExpoBeacon");
|
|
11
3
|
//# sourceMappingURL=ExpoBeaconModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoBeaconModule.js","sourceRoot":"","sources":["../src/ExpoBeaconModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAgFzD,
|
|
1
|
+
{"version":3,"file":"ExpoBeaconModule.js","sourceRoot":"","sources":["../src/ExpoBeaconModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAgFzD,eAAe,mBAAmB,CAAmB,YAAY,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\r\n\r\nimport {\r\n ExpoBeaconModuleEvents,\r\n BeaconScanResult,\r\n PairedBeacon,\r\n NotificationConfig,\r\n MonitoringOptions,\r\n} from \"./ExpoBeacon.types\";\r\n\r\ndeclare class ExpoBeaconModule extends NativeModule<ExpoBeaconModuleEvents> {\r\n /**\r\n * Start a one-shot iBeacon scan. Resolves with discovered beacons after scanDuration ms.\r\n *\r\n * Pass one or more UUIDs to scan for specific beacons (uses CoreLocation on iOS).\r\n * Pass an empty array or omit to perform a wildcard scan that discovers all nearby\r\n * iBeacons (uses CoreBluetooth on iOS — foreground only).\r\n *\r\n * @param uuids Proximity UUIDs to filter by. Empty/omitted = wildcard scan.\r\n * @param scanDuration Duration in ms (default 5000)\r\n */\r\n scanForBeaconsAsync(\r\n uuids?: string[],\r\n scanDuration?: number,\r\n ): Promise<BeaconScanResult[]>;\r\n\r\n /**\r\n * Register a beacon for persistent region monitoring.\r\n */\r\n pairBeacon(\r\n identifier: string,\r\n uuid: string,\r\n major: number,\r\n minor: number,\r\n ): void;\r\n\r\n /**\r\n * Remove a previously paired beacon.\r\n */\r\n unpairBeacon(identifier: string): void;\r\n\r\n /**\r\n * Return all currently paired beacons.\r\n */\r\n getPairedBeacons(): PairedBeacon[];\r\n\r\n /**\r\n * Set persistent notification configuration. Settings are saved and applied to all\r\n * subsequent monitoring sessions until explicitly changed.\r\n */\r\n setNotificationConfig(config: NotificationConfig): void;\r\n\r\n /**\r\n * Start background region monitoring for all paired beacons.\r\n * On Android starts a foreground service.\r\n * On iOS starts CLLocationManager region monitoring.\r\n *\r\n * Accepts a plain number (backward-compatible maxDistance shorthand) or a\r\n * MonitoringOptions object with maxDistance and/or notification overrides.\r\n */\r\n startMonitoring(options?: MonitoringOptions | number): Promise<void>;\r\n\r\n /**\r\n * Stop background region monitoring.\r\n */\r\n stopMonitoring(): Promise<void>;\r\n\r\n /**\r\n * Start a continuous BLE scan. Fires `onBeaconFound` events as beacons are detected.\r\n * Call stopContinuousScan() to end the scan.\r\n */\r\n startContinuousScan(): void;\r\n\r\n /** Stop the continuous scan started by startContinuousScan(). */\r\n stopContinuousScan(): void;\r\n\r\n /** Request Bluetooth + Location permissions. Returns true if granted. */\r\n requestPermissionsAsync(): Promise<boolean>;\r\n}\r\n\r\nexport default requireNativeModule<ExpoBeaconModule>(\"ExpoBeacon\");\r\n"]}
|
|
@@ -513,8 +513,11 @@ public class ExpoBeaconModule: Module {
|
|
|
513
513
|
|
|
514
514
|
fileprivate func handleDidChangeAuthorization(_ status: CLAuthorizationStatus) {
|
|
515
515
|
let granted = (status == .authorizedAlways || status == .authorizedWhenInUse)
|
|
516
|
-
permissionCompletion
|
|
516
|
+
// Nil out BEFORE calling so the closure can set a new permissionCompletion
|
|
517
|
+
// (e.g. the notDetermined → whenInUse → always two-step upgrade flow).
|
|
518
|
+
let completion = permissionCompletion
|
|
517
519
|
permissionCompletion = nil
|
|
520
|
+
completion?(granted)
|
|
518
521
|
}
|
|
519
522
|
|
|
520
523
|
fileprivate func handleDidRange(_ beacons: [CLBeacon], satisfying constraint: CLBeaconIdentityConstraint) {
|
|
@@ -713,8 +716,8 @@ private class LocationDelegate: NSObject, CLLocationManagerDelegate {
|
|
|
713
716
|
self.module = module
|
|
714
717
|
}
|
|
715
718
|
|
|
716
|
-
func
|
|
717
|
-
module?.handleDidChangeAuthorization(
|
|
719
|
+
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
|
|
720
|
+
module?.handleDidChangeAuthorization(manager.authorizationStatus)
|
|
718
721
|
}
|
|
719
722
|
|
|
720
723
|
func locationManager(_ manager: CLLocationManager, didRange beacons: [CLBeacon], satisfying constraint: CLBeaconIdentityConstraint) {
|
package/package.json
CHANGED
package/src/ExpoBeaconModule.ts
CHANGED
|
@@ -78,14 +78,4 @@ declare class ExpoBeaconModule extends NativeModule<ExpoBeaconModuleEvents> {
|
|
|
78
78
|
requestPermissionsAsync(): Promise<boolean>;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
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;
|
|
81
|
+
export default requireNativeModule<ExpoBeaconModule>("ExpoBeacon");
|