expo-beacon 0.10.1 → 0.10.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/README.md +136 -26
- package/android/src/main/java/expo/modules/beacon/BeaconForegroundService.kt +661 -385
- package/android/src/main/java/expo/modules/beacon/ExpoBeaconModule.kt +552 -233
- package/build/ExpoBeacon.types.d.ts +29 -7
- package/build/ExpoBeacon.types.d.ts.map +1 -1
- package/build/ExpoBeacon.types.js.map +1 -1
- package/build/ExpoBeaconModule.d.ts +11 -1
- package/build/ExpoBeaconModule.d.ts.map +1 -1
- package/build/ExpoBeaconModule.js.map +1 -1
- package/build/ExpoBeaconModule.web.d.ts.map +1 -1
- package/build/ExpoBeaconModule.web.js +5 -1
- package/build/ExpoBeaconModule.web.js.map +1 -1
- package/build/hooks/useBeacon.d.ts +5 -1
- package/build/hooks/useBeacon.d.ts.map +1 -1
- package/build/hooks/useBeacon.js +4 -0
- package/build/hooks/useBeacon.js.map +1 -1
- package/build/hooks/useCarPlay.d.ts +3 -1
- package/build/hooks/useCarPlay.d.ts.map +1 -1
- package/build/hooks/useCarPlay.js +2 -0
- package/build/hooks/useCarPlay.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/ios/ExpoBeaconModule+Monitoring.swift +5 -7
- package/ios/ExpoBeaconModule+Notifications.swift +38 -2
- package/ios/ExpoBeaconModule.swift +17 -4
- package/package.json +1 -1
- package/src/ExpoBeacon.types.ts +34 -10
- package/src/ExpoBeaconModule.ts +26 -4
- package/src/ExpoBeaconModule.web.ts +28 -6
- package/src/hooks/useBeacon.ts +39 -2
- package/src/hooks/useCarPlay.ts +13 -0
- package/src/index.ts +3 -4
package/README.md
CHANGED
|
@@ -271,6 +271,8 @@ function BeaconScreen() {
|
|
|
271
271
|
| `getMonitoringConfig()` | Read the current monitoring config + active-state snapshot. |
|
|
272
272
|
| `getMonitoredDeviceState()` / `getMonitoredDeviceStates()` | Native state snapshot for one / all paired devices. |
|
|
273
273
|
| `setNotificationConfig()` | Persist notification configuration for monitoring sessions. |
|
|
274
|
+
| `setBeaconNotificationConfig()` | Persist only beacon notification settings. |
|
|
275
|
+
| `setCarPlayNotificationConfig()` | Persist only CarPlay / Android Auto notification settings. |
|
|
274
276
|
| `enableEventLogging()` / `disableEventLogging()` | Toggle SQLite logging (updates `isEventLoggingEnabled`). |
|
|
275
277
|
| `getEventLogs()` / `clearEventLogs()` / `destroyEventLogs()` | Read / clear / drop the persisted event log. |
|
|
276
278
|
| `setApiEndpoint()` / `getApiEndpoint()` | Configure / read the native event-forwarding endpoint. |
|
|
@@ -660,28 +662,57 @@ await ExpoBeacon.startMonitoring();
|
|
|
660
662
|
|
|
661
663
|
```ts
|
|
662
664
|
ExpoBeacon.setNotificationConfig({
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
665
|
+
beacons: {
|
|
666
|
+
// Enter/exit/timeout alert notifications (both platforms)
|
|
667
|
+
events: {
|
|
668
|
+
enabled: true, // Set false to suppress beacon alerts
|
|
669
|
+
enterTitle: "Beacon nearby",
|
|
670
|
+
exitTitle: "Beacon out of range",
|
|
671
|
+
timeoutTitle: "Beacon timed out",
|
|
672
|
+
body: "{identifier} {event}ed", // Placeholders: {identifier}, {event}
|
|
673
|
+
sound: true, // iOS only
|
|
674
|
+
icon: "ic_beacon_notification", // Android only — drawable resource name
|
|
675
|
+
},
|
|
676
|
+
|
|
677
|
+
// Persistent status-bar notification for beacon monitoring (Android only)
|
|
678
|
+
foregroundService: {
|
|
679
|
+
title: "My App — Beacon monitoring",
|
|
680
|
+
text: "Watching for nearby beacons",
|
|
681
|
+
icon: "ic_service",
|
|
682
|
+
},
|
|
672
683
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
684
|
+
// Android notification channel for beacon notifications
|
|
685
|
+
channel: {
|
|
686
|
+
name: "Proximity Alerts",
|
|
687
|
+
description: "Alerts when beacons enter or leave range",
|
|
688
|
+
importance: "default", // "low" | "default" | "high"
|
|
689
|
+
},
|
|
678
690
|
},
|
|
679
691
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
692
|
+
carPlay: {
|
|
693
|
+
// Connect/disconnect notifications (both platforms)
|
|
694
|
+
events: {
|
|
695
|
+
enabled: true, // Set false to suppress CarPlay alerts
|
|
696
|
+
connectedTitle: "CarPlay connected",
|
|
697
|
+
disconnectedTitle: "CarPlay disconnected",
|
|
698
|
+
body: "CarPlay {event} {transport}", // Placeholders: {event}, {transport}
|
|
699
|
+
sound: true, // iOS only
|
|
700
|
+
icon: "ic_carplay_notification", // Android only — drawable resource name
|
|
701
|
+
},
|
|
702
|
+
|
|
703
|
+
// Persistent status-bar notification in CarPlay-only mode (Android only)
|
|
704
|
+
foregroundService: {
|
|
705
|
+
title: "My App — Vehicle monitoring",
|
|
706
|
+
text: "Monitoring CarPlay / Android Auto",
|
|
707
|
+
icon: "ic_service",
|
|
708
|
+
},
|
|
709
|
+
|
|
710
|
+
// Android notification channel for CarPlay notifications
|
|
711
|
+
channel: {
|
|
712
|
+
name: "CarPlay Alerts",
|
|
713
|
+
description: "CarPlay and Android Auto connection notifications",
|
|
714
|
+
importance: "default",
|
|
715
|
+
},
|
|
685
716
|
},
|
|
686
717
|
});
|
|
687
718
|
```
|
|
@@ -1323,10 +1354,28 @@ setNotificationConfig(config: NotificationConfig): void
|
|
|
1323
1354
|
|
|
1324
1355
|
Persists notification configuration applied to **all subsequent monitoring sessions**. Survives app restarts.
|
|
1325
1356
|
|
|
1326
|
-
For one-off overrides, pass `notifications` inside `startMonitoring(options)` instead.
|
|
1357
|
+
For one-off overrides, pass `notifications` inside `startMonitoring(options)` instead. Monitoring-time notification overrides are merged into the persisted notification config, so omitted beacon or CarPlay sections are preserved.
|
|
1358
|
+
|
|
1359
|
+
Use the top-level `beacons` and `carPlay` sections to configure those notification streams independently. Legacy keys (`beaconEvents`, `carPlayEvents`, `foregroundService`, `channel`, `carPlayChannel`) are still accepted for existing apps.
|
|
1327
1360
|
|
|
1328
1361
|
See [`NotificationConfig`](#notificationconfig) for the full shape.
|
|
1329
1362
|
|
|
1363
|
+
### `setBeaconNotificationConfig(config)`
|
|
1364
|
+
|
|
1365
|
+
```ts
|
|
1366
|
+
setBeaconNotificationConfig(config: BeaconNotificationSettings | BeaconNotificationConfig): void
|
|
1367
|
+
```
|
|
1368
|
+
|
|
1369
|
+
Persists only beacon notification settings without replacing CarPlay settings. Passing a plain `BeaconNotificationConfig` is treated as `beacons.events`.
|
|
1370
|
+
|
|
1371
|
+
### `setCarPlayNotificationConfig(config)`
|
|
1372
|
+
|
|
1373
|
+
```ts
|
|
1374
|
+
setCarPlayNotificationConfig(config: CarPlayNotificationSettings | CarPlayNotificationConfig): void
|
|
1375
|
+
```
|
|
1376
|
+
|
|
1377
|
+
Persists only CarPlay / Android Auto notification settings without replacing beacon settings. Passing a plain `CarPlayNotificationConfig` is treated as `carPlay.events`.
|
|
1378
|
+
|
|
1330
1379
|
---
|
|
1331
1380
|
|
|
1332
1381
|
### `enableEventLogging()`
|
|
@@ -1591,9 +1640,13 @@ import type {
|
|
|
1591
1640
|
ExpoBeaconModuleEvents,
|
|
1592
1641
|
MonitoringOptions,
|
|
1593
1642
|
NotificationConfig,
|
|
1643
|
+
BeaconNotificationSettings,
|
|
1594
1644
|
BeaconNotificationConfig,
|
|
1645
|
+
CarPlayNotificationSettings,
|
|
1646
|
+
CarPlayNotificationConfig,
|
|
1595
1647
|
ForegroundServiceConfig,
|
|
1596
1648
|
NotificationChannelConfig,
|
|
1649
|
+
CarPlayChannelConfig,
|
|
1597
1650
|
EventLogQueryOptions,
|
|
1598
1651
|
EventLogEntry,
|
|
1599
1652
|
} from "expo-beacon";
|
|
@@ -1774,9 +1827,35 @@ Top-level notification configuration.
|
|
|
1774
1827
|
|
|
1775
1828
|
```ts
|
|
1776
1829
|
type NotificationConfig = {
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1830
|
+
beacons?: BeaconNotificationSettings;
|
|
1831
|
+
carPlay?: CarPlayNotificationSettings;
|
|
1832
|
+
|
|
1833
|
+
// Legacy aliases, still accepted:
|
|
1834
|
+
beaconEvents?: BeaconNotificationConfig;
|
|
1835
|
+
carPlayEvents?: CarPlayNotificationConfig;
|
|
1836
|
+
foregroundService?: ForegroundServiceConfig;
|
|
1837
|
+
channel?: NotificationChannelConfig;
|
|
1838
|
+
carPlayChannel?: CarPlayChannelConfig;
|
|
1839
|
+
};
|
|
1840
|
+
```
|
|
1841
|
+
|
|
1842
|
+
### `BeaconNotificationSettings`
|
|
1843
|
+
|
|
1844
|
+
```ts
|
|
1845
|
+
type BeaconNotificationSettings = {
|
|
1846
|
+
events?: BeaconNotificationConfig;
|
|
1847
|
+
foregroundService?: ForegroundServiceConfig; // Android only
|
|
1848
|
+
channel?: NotificationChannelConfig; // Android only
|
|
1849
|
+
};
|
|
1850
|
+
```
|
|
1851
|
+
|
|
1852
|
+
### `CarPlayNotificationSettings`
|
|
1853
|
+
|
|
1854
|
+
```ts
|
|
1855
|
+
type CarPlayNotificationSettings = {
|
|
1856
|
+
events?: CarPlayNotificationConfig;
|
|
1857
|
+
foregroundService?: ForegroundServiceConfig; // Android only, CarPlay-only mode
|
|
1858
|
+
channel?: CarPlayChannelConfig; // Android only
|
|
1780
1859
|
};
|
|
1781
1860
|
```
|
|
1782
1861
|
|
|
@@ -1815,6 +1894,30 @@ type NotificationChannelConfig = {
|
|
|
1815
1894
|
};
|
|
1816
1895
|
```
|
|
1817
1896
|
|
|
1897
|
+
### `CarPlayNotificationConfig`
|
|
1898
|
+
|
|
1899
|
+
```ts
|
|
1900
|
+
type CarPlayNotificationConfig = {
|
|
1901
|
+
enabled?: boolean; // Default: true. Set false to suppress.
|
|
1902
|
+
connectedTitle?: string; // Default: "CarPlay Connected"
|
|
1903
|
+
disconnectedTitle?: string; // Default: "CarPlay Disconnected"
|
|
1904
|
+
body?: string; // Default: "CarPlay session {event}"
|
|
1905
|
+
// Supports {event} and {transport} placeholders.
|
|
1906
|
+
sound?: boolean; // iOS only. Default: true
|
|
1907
|
+
icon?: string; // Android only. Drawable resource name.
|
|
1908
|
+
};
|
|
1909
|
+
```
|
|
1910
|
+
|
|
1911
|
+
### `CarPlayChannelConfig`
|
|
1912
|
+
|
|
1913
|
+
```ts
|
|
1914
|
+
type CarPlayChannelConfig = {
|
|
1915
|
+
name?: string; // Default: "CarPlay / Android Auto"
|
|
1916
|
+
description?: string; // Default: "CarPlay and Android Auto connect/disconnect notifications"
|
|
1917
|
+
importance?: "low" | "default" | "high"; // Default: "default"
|
|
1918
|
+
};
|
|
1919
|
+
```
|
|
1920
|
+
|
|
1818
1921
|
### `BeaconTimeoutEvent`
|
|
1819
1922
|
|
|
1820
1923
|
Payload for `onBeaconTimeout`.
|
|
@@ -2101,7 +2204,7 @@ override fun onCreate() {
|
|
|
2101
2204
|
|
|
2102
2205
|
## Notifications
|
|
2103
2206
|
|
|
2104
|
-
|
|
2207
|
+
Local notifications are posted automatically for beacon enter/exit/timeout events and CarPlay / Android Auto connect/disconnect events. Beacon notifications and CarPlay notifications have separate configuration sections and separate Android channels.
|
|
2105
2208
|
|
|
2106
2209
|
### Default Values
|
|
2107
2210
|
|
|
@@ -2110,16 +2213,23 @@ A local notification is posted automatically for every beacon enter/exit event (
|
|
|
2110
2213
|
| Enter title | `"Beacon Entered"` |
|
|
2111
2214
|
| Exit title | `"Beacon Exited"` |
|
|
2112
2215
|
| Body | `"{identifier} region {event}ed"` |
|
|
2216
|
+
| CarPlay connected title | `"CarPlay Connected"` |
|
|
2217
|
+
| CarPlay disconnected title | `"CarPlay Disconnected"` |
|
|
2218
|
+
| CarPlay body | `"CarPlay session {event}"` |
|
|
2113
2219
|
| Sound (iOS) | `true` |
|
|
2114
2220
|
| Icon (Android) | System `ic_dialog_info` |
|
|
2115
2221
|
| Foreground service title | `"Beacon Monitoring Active"` |
|
|
2116
2222
|
| Foreground service text | `"Monitoring for iBeacons in the background"` |
|
|
2223
|
+
| CarPlay-only foreground title | `"Connected device monitoring active"` |
|
|
2224
|
+
| CarPlay-only foreground text | `"Monitoring connected vehicle (CarPlay/Android Auto)"` |
|
|
2117
2225
|
| Channel name (Android) | `"Beacon Monitoring"` |
|
|
2118
2226
|
| Channel importance (Android) | `"low"` |
|
|
2227
|
+
| CarPlay channel name (Android) | `"CarPlay / Android Auto"` |
|
|
2228
|
+
| CarPlay channel importance (Android) | `"default"` |
|
|
2119
2229
|
|
|
2120
|
-
### Android
|
|
2230
|
+
### Android Channels
|
|
2121
2231
|
|
|
2122
|
-
|
|
2232
|
+
Beacon foreground-service and event notifications use the channel ID `expo_beacon_channel`. CarPlay / Android Auto event notifications use `expo_beacon_carplay_channel`; when Android runs in CarPlay-only mode, the foreground-service notification also uses the CarPlay channel and `carPlay.foregroundService` config.
|
|
2123
2233
|
|
|
2124
2234
|
> **Android channel importance note**: Android prevents decreasing channel importance after the first notification. Increasing works; decreasing has no effect until the user clears notification settings or reinstalls the app.
|
|
2125
2235
|
|