expo-beacon 0.10.3 → 0.10.5
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 +9 -5
- package/android/src/main/java/expo/modules/beacon/BeaconForegroundService.kt +32 -3
- package/package.json +1 -1
- package/plugin/build/withBeaconAndroid.d.ts +2 -2
- package/plugin/build/withBeaconAndroid.d.ts.map +1 -1
- package/plugin/build/withBeaconAndroid.js +55 -38
- package/plugin/build/withBeaconIOS.d.ts.map +1 -1
- package/plugin/build/withBeaconIOS.js +1 -0
package/README.md
CHANGED
|
@@ -1844,8 +1844,8 @@ type NotificationConfig = {
|
|
|
1844
1844
|
```ts
|
|
1845
1845
|
type BeaconNotificationSettings = {
|
|
1846
1846
|
events?: BeaconNotificationConfig;
|
|
1847
|
-
foregroundService?: ForegroundServiceConfig; // Android only
|
|
1848
|
-
channel?: NotificationChannelConfig; // Android only
|
|
1847
|
+
foregroundService?: ForegroundServiceConfig; // Android only, title/text/icon only
|
|
1848
|
+
channel?: NotificationChannelConfig; // Android only, beacon alert channel
|
|
1849
1849
|
};
|
|
1850
1850
|
```
|
|
1851
1851
|
|
|
@@ -1854,8 +1854,8 @@ type BeaconNotificationSettings = {
|
|
|
1854
1854
|
```ts
|
|
1855
1855
|
type CarPlayNotificationSettings = {
|
|
1856
1856
|
events?: CarPlayNotificationConfig;
|
|
1857
|
-
foregroundService?: ForegroundServiceConfig; // Android only, CarPlay-only
|
|
1858
|
-
channel?: CarPlayChannelConfig; // Android only
|
|
1857
|
+
foregroundService?: ForegroundServiceConfig; // Android only, CarPlay-only title/text/icon
|
|
1858
|
+
channel?: CarPlayChannelConfig; // Android only, CarPlay alert channel
|
|
1859
1859
|
};
|
|
1860
1860
|
```
|
|
1861
1861
|
|
|
@@ -1884,6 +1884,8 @@ type ForegroundServiceConfig = {
|
|
|
1884
1884
|
};
|
|
1885
1885
|
```
|
|
1886
1886
|
|
|
1887
|
+
Foreground service notifications always use the dedicated Android channel `expo_beacon_foreground_channel`, created with low importance and no sound/vibration. This config only changes the notification content.
|
|
1888
|
+
|
|
1887
1889
|
### `NotificationChannelConfig`
|
|
1888
1890
|
|
|
1889
1891
|
```ts
|
|
@@ -2222,6 +2224,8 @@ Local notifications are posted automatically for beacon enter/exit/timeout event
|
|
|
2222
2224
|
| Foreground service text | `"Monitoring for iBeacons in the background"` |
|
|
2223
2225
|
| CarPlay-only foreground title | `"Connected device monitoring active"` |
|
|
2224
2226
|
| CarPlay-only foreground text | `"Monitoring connected vehicle (CarPlay/Android Auto)"` |
|
|
2227
|
+
| Foreground channel name (Android) | `"Beacon Foreground Service"` |
|
|
2228
|
+
| Foreground channel importance (Android) | `"low"` (no sound/vibration) |
|
|
2225
2229
|
| Channel name (Android) | `"Beacon Monitoring"` |
|
|
2226
2230
|
| Channel importance (Android) | `"low"` |
|
|
2227
2231
|
| CarPlay channel name (Android) | `"CarPlay / Android Auto"` |
|
|
@@ -2229,7 +2233,7 @@ Local notifications are posted automatically for beacon enter/exit/timeout event
|
|
|
2229
2233
|
|
|
2230
2234
|
### Android Channels
|
|
2231
2235
|
|
|
2232
|
-
|
|
2236
|
+
Foreground-service notifications use their own quiet channel ID, `expo_beacon_foreground_channel`, so the persistent status notification does not make sound or vibrate. Beacon event notifications use `expo_beacon_channel`; CarPlay / Android Auto event notifications use `expo_beacon_carplay_channel`. In CarPlay-only mode, the foreground-service notification still uses the quiet foreground channel but reads title/text/icon from `carPlay.foregroundService`.
|
|
2233
2237
|
|
|
2234
2238
|
> **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.
|
|
2235
2239
|
|
|
@@ -19,6 +19,7 @@ import org.altbeacon.beacon.*
|
|
|
19
19
|
import org.json.JSONArray
|
|
20
20
|
|
|
21
21
|
private const val CHANNEL_ID = "expo_beacon_channel"
|
|
22
|
+
private const val FOREGROUND_CHANNEL_ID = "expo_beacon_foreground_channel"
|
|
22
23
|
private const val CARPLAY_CHANNEL_ID = "expo_beacon_carplay_channel"
|
|
23
24
|
internal const val FOREGROUND_NOTIF_ID = 1001
|
|
24
25
|
/**
|
|
@@ -102,6 +103,7 @@ class BeaconForegroundService : Service(), BeaconConsumer {
|
|
|
102
103
|
override fun onCreate() {
|
|
103
104
|
super.onCreate()
|
|
104
105
|
activeService = this
|
|
106
|
+
ensureForegroundNotificationChannel(this)
|
|
105
107
|
ensureNotificationChannel(this)
|
|
106
108
|
ensureCarPlayNotificationChannel(this)
|
|
107
109
|
apiForwarder = BeaconApiForwarder(this)
|
|
@@ -1239,6 +1241,7 @@ class BeaconForegroundService : Service(), BeaconConsumer {
|
|
|
1239
1241
|
.edit()
|
|
1240
1242
|
.putBoolean(MONITORING_ACTIVE_KEY, true)
|
|
1241
1243
|
.apply()
|
|
1244
|
+
ensureForegroundNotificationChannel(context)
|
|
1242
1245
|
ensureNotificationChannel(context)
|
|
1243
1246
|
ensureCarPlayNotificationChannel(context)
|
|
1244
1247
|
val intent = Intent(context, BeaconForegroundService::class.java)
|
|
@@ -1307,6 +1310,7 @@ class BeaconForegroundService : Service(), BeaconConsumer {
|
|
|
1307
1310
|
*/
|
|
1308
1311
|
fun enableCarPlay(context: Context) {
|
|
1309
1312
|
setCarPlayEnabled(context, true)
|
|
1313
|
+
ensureForegroundNotificationChannel(context)
|
|
1310
1314
|
ensureNotificationChannel(context)
|
|
1311
1315
|
ensureCarPlayNotificationChannel(context)
|
|
1312
1316
|
// Arm the WorkManager watchdog (15-min periodic safety net) and the
|
|
@@ -1570,12 +1574,38 @@ class BeaconForegroundService : Service(), BeaconConsumer {
|
|
|
1570
1574
|
NotificationManager.IMPORTANCE_DEFAULT
|
|
1571
1575
|
)
|
|
1572
1576
|
|
|
1577
|
+
/**
|
|
1578
|
+
* Ensure the persistent foreground-service notification has a quiet channel of its own.
|
|
1579
|
+
* Event channels can be default/high importance, but the always-on service status should
|
|
1580
|
+
* never make sound or vibrate.
|
|
1581
|
+
*/
|
|
1582
|
+
fun ensureForegroundNotificationChannel(context: Context) {
|
|
1583
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
|
|
1584
|
+
val notifMgr = context.getSystemService(NotificationManager::class.java)
|
|
1585
|
+
if (notifMgr?.getNotificationChannel(FOREGROUND_CHANNEL_ID) == null) {
|
|
1586
|
+
val channel =
|
|
1587
|
+
NotificationChannel(
|
|
1588
|
+
FOREGROUND_CHANNEL_ID,
|
|
1589
|
+
"Beacon Foreground Service",
|
|
1590
|
+
NotificationManager.IMPORTANCE_LOW
|
|
1591
|
+
)
|
|
1592
|
+
.apply {
|
|
1593
|
+
description =
|
|
1594
|
+
"Persistent status for beacon and CarPlay background monitoring"
|
|
1595
|
+
setSound(null, null)
|
|
1596
|
+
enableVibration(false)
|
|
1597
|
+
}
|
|
1598
|
+
notifMgr?.createNotificationChannel(channel)
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1573
1602
|
/**
|
|
1574
1603
|
* Build the persistent foreground-service notification from any Context. Static so
|
|
1575
1604
|
* cold-start paths that run before a service instance exists (e.g. [BootReceiver]) read the
|
|
1576
1605
|
* same persisted config.
|
|
1577
1606
|
*/
|
|
1578
1607
|
fun buildForegroundNotification(context: Context): Notification {
|
|
1608
|
+
ensureForegroundNotificationChannel(context)
|
|
1579
1609
|
val config = readNotificationConfig(context)
|
|
1580
1610
|
|
|
1581
1611
|
// If beacon monitoring is not active and the service is alive only
|
|
@@ -1605,16 +1635,15 @@ class BeaconForegroundService : Service(), BeaconConsumer {
|
|
|
1605
1635
|
"foregroundService"
|
|
1606
1636
|
)
|
|
1607
1637
|
}
|
|
1608
|
-
val channelId = if (carPlayOnly) CARPLAY_CHANNEL_ID else CHANNEL_ID
|
|
1609
|
-
|
|
1610
1638
|
val title = fgConfig?.optString("title")?.takeIf { it.isNotEmpty() } ?: defaultTitle
|
|
1611
1639
|
val text = fgConfig?.optString("text")?.takeIf { it.isNotEmpty() } ?: defaultText
|
|
1612
1640
|
|
|
1613
|
-
return NotificationCompat.Builder(context,
|
|
1641
|
+
return NotificationCompat.Builder(context, FOREGROUND_CHANNEL_ID)
|
|
1614
1642
|
.setSmallIcon(resolveIconRes(context, fgConfig))
|
|
1615
1643
|
.setContentTitle(title)
|
|
1616
1644
|
.setContentText(text)
|
|
1617
1645
|
.setPriority(NotificationCompat.PRIORITY_LOW)
|
|
1646
|
+
.setSilent(true)
|
|
1618
1647
|
.setOngoing(true)
|
|
1619
1648
|
.build()
|
|
1620
1649
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigPlugin } from
|
|
1
|
+
import { ConfigPlugin } from "@expo/config-plugins";
|
|
2
2
|
/**
|
|
3
3
|
* Categories advertised in the generated `automotive_app_desc.xml` resource.
|
|
4
4
|
* - `template` — declares the app as a Car-App-Library template provider. This
|
|
@@ -11,7 +11,7 @@ import { ConfigPlugin } from '@expo/config-plugins';
|
|
|
11
11
|
* package as AA-aware for connection detection. Use this when the consumer
|
|
12
12
|
* app shouldn't appear in the AA drawer at all.
|
|
13
13
|
*/
|
|
14
|
-
export type AndroidAutoUsesName =
|
|
14
|
+
export type AndroidAutoUsesName = "template" | "media" | "notification";
|
|
15
15
|
export type BeaconAndroidPluginProps = {
|
|
16
16
|
/**
|
|
17
17
|
* Generate `BeaconGeoPlugin.kt` and register it in `MainApplication.kt` so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withBeaconAndroid.d.ts","sourceRoot":"","sources":["../src/withBeaconAndroid.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAGb,MAAM,sBAAsB,CAAC;AAM9B;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC;AAExE,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE;QACZ;2EACmE;QACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB;qCAC6B;QAC7B,QAAQ,CAAC,EAAE,mBAAmB,CAAC;KAChC,CAAC;CACH,CAAC;AAIF,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"withBeaconAndroid.d.ts","sourceRoot":"","sources":["../src/withBeaconAndroid.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAGb,MAAM,sBAAsB,CAAC;AAM9B;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC;AAExE,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE;QACZ;2EACmE;QACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB;qCAC6B;QAC7B,QAAQ,CAAC,EAAE,mBAAmB,CAAC;KAChC,CAAC;CACH,CAAC;AAIF,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAsDlE;AAoMD,QAAA,MAAM,iBAAiB,EAAE,YAAY,CAAC,wBAAwB,GAAG,IAAI,CA0BpE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -12,6 +12,8 @@ package ${packageName}
|
|
|
12
12
|
import android.content.Context
|
|
13
13
|
import com.transistorsoft.locationmanager.adapter.BackgroundGeolocation
|
|
14
14
|
import com.transistorsoft.locationmanager.adapter.callback.TSCallback
|
|
15
|
+
import com.transistorsoft.locationmanager.adapter.callback.TSSyncCallback
|
|
16
|
+
import com.transistorsoft.locationmanager.location.TSLocation
|
|
15
17
|
import expo.modules.beacon.BeaconEventPlugin
|
|
16
18
|
|
|
17
19
|
class BeaconGeoPlugin(ctx: Context) : BeaconEventPlugin {
|
|
@@ -20,56 +22,71 @@ class BeaconGeoPlugin(ctx: Context) : BeaconEventPlugin {
|
|
|
20
22
|
override fun onSuccess() {}
|
|
21
23
|
override fun onFailure(error: String) {}
|
|
22
24
|
}
|
|
25
|
+
private val noOpSync = object : TSSyncCallback {
|
|
26
|
+
override fun onSuccess(records: MutableList<TSLocation>) {}
|
|
27
|
+
override fun onFailure(error: String) {}
|
|
28
|
+
}
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
private fun startTracking() {
|
|
25
31
|
bgGeo.start(noOp)
|
|
26
|
-
|
|
32
|
+
bgGeo.changePace(true, noOp)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private fun stopTracking() {
|
|
36
|
+
bgGeo.sync(noOpSync)
|
|
37
|
+
bgGeo.changePace(false, noOp)
|
|
27
38
|
bgGeo.stop(noOp)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override fun onBeaconEnter(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) =
|
|
42
|
+
startTracking()
|
|
43
|
+
override fun onBeaconExit(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) =
|
|
44
|
+
stopTracking()
|
|
28
45
|
override fun onBeaconTimeout(identifier: String, uuid: String, major: Int, minor: Int, distance: Double) =
|
|
29
|
-
|
|
46
|
+
stopTracking()
|
|
30
47
|
override fun onEddystoneEnter(identifier: String, namespace: String, instance: String, distance: Double) =
|
|
31
|
-
|
|
48
|
+
startTracking()
|
|
32
49
|
override fun onEddystoneExit(identifier: String, namespace: String, instance: String, distance: Double) =
|
|
33
|
-
|
|
50
|
+
stopTracking()
|
|
34
51
|
override fun onEddystoneTimeout(identifier: String, namespace: String, instance: String, distance: Double) =
|
|
35
|
-
|
|
52
|
+
stopTracking()
|
|
36
53
|
// Start tracking when the device connects to Android Auto, stop when it disconnects.
|
|
37
54
|
override fun onCarPlayConnected(transport: String) {
|
|
38
|
-
|
|
55
|
+
startTracking()
|
|
39
56
|
}
|
|
40
57
|
override fun onCarPlayDisconnected() {
|
|
41
|
-
|
|
58
|
+
stopTracking()
|
|
42
59
|
}
|
|
43
60
|
}
|
|
44
61
|
`;
|
|
45
62
|
}
|
|
46
63
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
47
64
|
function modifyMainApplication(contents) {
|
|
48
|
-
const importLine =
|
|
65
|
+
const importLine = "import expo.modules.beacon.BeaconPluginRegistry";
|
|
49
66
|
// Add missing import after the last existing import.
|
|
50
67
|
if (!contents.includes(importLine)) {
|
|
51
|
-
const lines = contents.split(
|
|
52
|
-
const lastImportIdx = lines.reduce((last, line, i) => (line.trimStart().startsWith(
|
|
68
|
+
const lines = contents.split("\n");
|
|
69
|
+
const lastImportIdx = lines.reduce((last, line, i) => (line.trimStart().startsWith("import ") ? i : last), -1);
|
|
53
70
|
if (lastImportIdx >= 0) {
|
|
54
71
|
lines.splice(lastImportIdx + 1, 0, importLine);
|
|
55
72
|
}
|
|
56
73
|
else {
|
|
57
|
-
const pkgIdx = lines.findIndex((l) => l.startsWith(
|
|
58
|
-
lines.splice(pkgIdx >= 0 ? pkgIdx + 1 : 0, 0,
|
|
74
|
+
const pkgIdx = lines.findIndex((l) => l.startsWith("package "));
|
|
75
|
+
lines.splice(pkgIdx >= 0 ? pkgIdx + 1 : 0, 0, "", importLine);
|
|
59
76
|
}
|
|
60
|
-
contents = lines.join(
|
|
77
|
+
contents = lines.join("\n");
|
|
61
78
|
}
|
|
62
79
|
// Add registration call immediately after `super.onCreate()`.
|
|
63
|
-
const registration =
|
|
64
|
-
if (!contents.includes(
|
|
80
|
+
const registration = " BeaconPluginRegistry.register(BeaconGeoPlugin(this))";
|
|
81
|
+
if (!contents.includes("BeaconPluginRegistry.register(BeaconGeoPlugin(this))")) {
|
|
65
82
|
contents = contents.replace(/(super\.onCreate\(\)[ \t]*\n)/, `$1${registration}\n`);
|
|
66
83
|
}
|
|
67
84
|
return contents;
|
|
68
85
|
}
|
|
69
86
|
// ─── Plugin ───────────────────────────────────────────────────────────────────
|
|
70
|
-
const AA_META_DATA_NAME =
|
|
71
|
-
const AA_META_DATA_RESOURCE =
|
|
72
|
-
const AA_RES_FILE =
|
|
87
|
+
const AA_META_DATA_NAME = "com.google.android.gms.car.application";
|
|
88
|
+
const AA_META_DATA_RESOURCE = "@xml/automotive_app_desc";
|
|
89
|
+
const AA_RES_FILE = "automotive_app_desc.xml";
|
|
73
90
|
function getAutomotiveAppDescXml(usesName) {
|
|
74
91
|
return `<?xml version="1.0" encoding="utf-8"?>
|
|
75
92
|
<!--
|
|
@@ -98,7 +115,7 @@ const withAndroidAutoMetaData = (config) => {
|
|
|
98
115
|
// User-managed entry; leave it alone.
|
|
99
116
|
return config;
|
|
100
117
|
}
|
|
101
|
-
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(app, AA_META_DATA_NAME, AA_META_DATA_RESOURCE,
|
|
118
|
+
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(app, AA_META_DATA_NAME, AA_META_DATA_RESOURCE, "resource");
|
|
102
119
|
return config;
|
|
103
120
|
});
|
|
104
121
|
};
|
|
@@ -109,9 +126,9 @@ const withAndroidAutoMetaData = (config) => {
|
|
|
109
126
|
*/
|
|
110
127
|
function withAndroidAutoDescriptor(usesName) {
|
|
111
128
|
return (config) => (0, config_plugins_1.withDangerousMod)(config, [
|
|
112
|
-
|
|
129
|
+
"android",
|
|
113
130
|
(config) => {
|
|
114
|
-
const xmlDir = path.join(config.modRequest.platformProjectRoot,
|
|
131
|
+
const xmlDir = path.join(config.modRequest.platformProjectRoot, "app/src/main/res/xml");
|
|
115
132
|
const xmlPath = path.join(xmlDir, AA_RES_FILE);
|
|
116
133
|
if (fs.existsSync(xmlPath)) {
|
|
117
134
|
// Don't clobber a user-managed resource.
|
|
@@ -135,47 +152,47 @@ function withAndroidAutoDescriptor(usesName) {
|
|
|
135
152
|
const withBeaconGeoPlugin = (config) => {
|
|
136
153
|
// Step 1 – write BeaconGeoPlugin.kt into the app source tree.
|
|
137
154
|
config = (0, config_plugins_1.withDangerousMod)(config, [
|
|
138
|
-
|
|
155
|
+
"android",
|
|
139
156
|
(config) => {
|
|
140
157
|
var _a;
|
|
141
158
|
const pkgName = (_a = config.android) === null || _a === void 0 ? void 0 : _a.package;
|
|
142
159
|
if (!pkgName) {
|
|
143
|
-
console.warn(
|
|
160
|
+
console.warn("[expo-beacon] android.package not set — BeaconGeoPlugin.kt was not written.");
|
|
144
161
|
return config;
|
|
145
162
|
}
|
|
146
|
-
const pkgPath = pkgName.replace(/\./g,
|
|
147
|
-
const outputPath = path.join(config.modRequest.platformProjectRoot,
|
|
163
|
+
const pkgPath = pkgName.replace(/\./g, "/");
|
|
164
|
+
const outputPath = path.join(config.modRequest.platformProjectRoot, "app/src/main/java", pkgPath, "BeaconGeoPlugin.kt");
|
|
148
165
|
fs.writeFileSync(outputPath, getAndroidPluginKotlin(pkgName));
|
|
149
166
|
return config;
|
|
150
167
|
},
|
|
151
168
|
]);
|
|
152
169
|
// Step 2 – patch MainApplication (Kotlin only) to call register().
|
|
153
170
|
config = (0, config_plugins_1.withDangerousMod)(config, [
|
|
154
|
-
|
|
171
|
+
"android",
|
|
155
172
|
(config) => {
|
|
156
173
|
var _a;
|
|
157
174
|
const pkgName = (_a = config.android) === null || _a === void 0 ? void 0 : _a.package;
|
|
158
175
|
if (!pkgName)
|
|
159
176
|
return config;
|
|
160
|
-
const pkgPath = pkgName.replace(/\./g,
|
|
161
|
-
const javaRoot = path.join(config.modRequest.platformProjectRoot,
|
|
177
|
+
const pkgPath = pkgName.replace(/\./g, "/");
|
|
178
|
+
const javaRoot = path.join(config.modRequest.platformProjectRoot, "app/src/main/java", pkgPath);
|
|
162
179
|
const mainAppPath = [
|
|
163
|
-
path.join(javaRoot,
|
|
164
|
-
path.join(javaRoot,
|
|
180
|
+
path.join(javaRoot, "MainApplication.kt"),
|
|
181
|
+
path.join(javaRoot, "MainApplication.java"),
|
|
165
182
|
].find(fs.existsSync);
|
|
166
183
|
if (!mainAppPath) {
|
|
167
|
-
console.warn(
|
|
168
|
-
|
|
184
|
+
console.warn("[expo-beacon] MainApplication.kt / .java not found — " +
|
|
185
|
+
"please add BeaconPluginRegistry.register(BeaconGeoPlugin(this)) manually.");
|
|
169
186
|
return config;
|
|
170
187
|
}
|
|
171
188
|
// The injected import + registration use Kotlin syntax and would corrupt
|
|
172
189
|
// a Java MainApplication — leave Java projects untouched.
|
|
173
|
-
if (mainAppPath.endsWith(
|
|
174
|
-
console.warn(
|
|
175
|
-
|
|
190
|
+
if (mainAppPath.endsWith(".java")) {
|
|
191
|
+
console.warn("[expo-beacon] MainApplication.java (Java) cannot be patched automatically — " +
|
|
192
|
+
"please add BeaconPluginRegistry.register(BeaconGeoPlugin(this)) manually.");
|
|
176
193
|
return config;
|
|
177
194
|
}
|
|
178
|
-
const original = fs.readFileSync(mainAppPath,
|
|
195
|
+
const original = fs.readFileSync(mainAppPath, "utf-8");
|
|
179
196
|
fs.writeFileSync(mainAppPath, modifyMainApplication(original));
|
|
180
197
|
return config;
|
|
181
198
|
},
|
|
@@ -186,7 +203,7 @@ const withBeaconAndroid = (config, props) => {
|
|
|
186
203
|
var _a, _b, _c, _d, _e;
|
|
187
204
|
const opts = props !== null && props !== void 0 ? props : {};
|
|
188
205
|
const aaRegister = (_b = (_a = opts.androidAuto) === null || _a === void 0 ? void 0 : _a.register) !== null && _b !== void 0 ? _b : true;
|
|
189
|
-
const aaUsesName = (_d = (_c = opts.androidAuto) === null || _c === void 0 ? void 0 : _c.usesName) !== null && _d !== void 0 ? _d :
|
|
206
|
+
const aaUsesName = (_d = (_c = opts.androidAuto) === null || _c === void 0 ? void 0 : _c.usesName) !== null && _d !== void 0 ? _d : "template";
|
|
190
207
|
// Steps 1–2 – BeaconGeoPlugin generation + MainApplication registration
|
|
191
208
|
// (react-native-background-geolocation integration). Opt-out via
|
|
192
209
|
// `backgroundGeolocation: false`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withBeaconIOS.d.ts","sourceRoot":"","sources":["../src/withBeaconIOS.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAKb,MAAM,sBAAsB,CAAC;AAM9B,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAIF,wBAAgB,iBAAiB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"withBeaconIOS.d.ts","sourceRoot":"","sources":["../src/withBeaconIOS.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAKb,MAAM,sBAAsB,CAAC;AAM9B,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAIF,wBAAgB,iBAAiB,IAAI,MAAM,CA6C1C;AA2KD,QAAA,MAAM,aAAa,EAAE,YAAY,CAAC,oBAAoB,GAAG,IAAI,CAgC5D,CAAC;AA6CF,eAAe,aAAa,CAAC"}
|