From 5c0da4a722d45f60fca2136a4a950af5151a8e68 Mon Sep 17 00:00:00 2001 From: Chris Scott Date: Thu, 5 Sep 2024 11:17:05 -0400 Subject: [PATCH] Fix expo plugin license key management related to unused polygon license causing license validation error --- CHANGELOG.md | 3 +++ expo/plugin/src/androidPlugin.ts | 31 +++++++++++++++++++++++++------ package.json | 2 +- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72601ec2..30fe14a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## 4.17.1 — 2024-09-05 +* [Expo] Fix bug in Expo plugin adding unused license keys for "polygon geofencing" with a value of `UNDEFINED`, causing license-validation error. Add logic to automatically remove license keys from `AndroidManifest` when corresponding keys are not found in your `app.json` (eg: `polygonLicense`). + ## 4.17.0 — 2024-09-04 * [iOS] Fix bug in iOS *Polygon Geofencing* when running in geofences-only mode (`.startGeofences`). iOS would mistakenly turn off location updates exactly 3 samples into the containing circular geofence of a polygon. * Implement `notifyOnDwell` for polygon-geofences. diff --git a/expo/plugin/src/androidPlugin.ts b/expo/plugin/src/androidPlugin.ts index 83ea9693..9ae045e3 100644 --- a/expo/plugin/src/androidPlugin.ts +++ b/expo/plugin/src/androidPlugin.ts @@ -53,7 +53,12 @@ if (!MODULE_NAME) { process.exit(1); } -const { addMetaDataItemToMainApplication, getMainApplicationOrThrow } = AndroidConfig.Manifest; +const { + addMetaDataItemToMainApplication, + removeMetaDataItemFromMainApplication, + getMainApplicationOrThrow +} = AndroidConfig.Manifest; + const androidPlugin: ConfigPlugin = (config, props={}) => { config = withProjectBuildGradle(config, ({ modResults, ...subConfig }) => { @@ -86,6 +91,8 @@ const androidPlugin: ConfigPlugin = (config, props={}) => { config = withAndroidManifest(config, async (config) => { + console.log("[react-native-background-geolocation] Adding license-keys to AndroidManifest:", props); + const mainApplication = getMainApplicationOrThrow(config.modResults); addMetaDataItemToMainApplication( @@ -93,17 +100,29 @@ const androidPlugin: ConfigPlugin = (config, props={}) => { META_LICENSE_KEY, props.license || "UNDEFINED" ); - addMetaDataItemToMainApplication( - mainApplication, - META_HMS_LICENSE_KEY, - props.hmsLicense || "UNDEFINED" - ); + if (props.hmsLicense) { + addMetaDataItemToMainApplication( + mainApplication, + META_HMS_LICENSE_KEY, + props.hmsLicense + ); + } else { + removeMetaDataItemFromMainApplication( + mainApplication, + META_HMS_LICENSE_KEY + ); + } if (props.polygonLicense) { addMetaDataItemToMainApplication( mainApplication, META_POLYGON_LICENSE_KEY, props.polygonLicense ); + } else { + removeMetaDataItemFromMainApplication( + mainApplication, + META_POLYGON_LICENSE_KEY + ); } return config; diff --git a/package.json b/package.json index 8e5689ce..ebcfefee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-background-geolocation", - "version": "4.17.0", + "version": "4.17.1", "description": "The most sophisticated cross-platform background location-tracking & geofencing module with battery-conscious motion-detection intelligence", "scripts": { "build": "yarn run build:expo",