I am trying to get Geofencing working in my managed app but I am running into a hurdle when enabling ‘Background Location’.
Despite updating my app.json
file with the workaround suggested in the documentation I keep receiving the following error when calling Location.startGeofencingAsync(taskName, region)
:
Error: Background Location has not been configured. To enable it, add `location` to `UIBackgroundModes` in Info.plist file.
As a managed app, I do not have access to the Info.plist file and updating the app.json
file appears to have no effect.
I have tried both a macintosh machine and a windows machine as well as previous versions of the expo-cli from 18.0.0 → 19.5.0
I would really appreciate some guidance or help to remove this error.
FYI, I can re-create the error by running expo init
, expo install expo-location
and adding the following to the app.js
file:
timport React from "react";
import { StyleSheet, Text, View } from "react-native";
import * as Location from "expo-location";
export default function App() {
Location.startGeofencingAsync("test", [
{ latitude: 37, longitude: 144, radius: 15 }
])
.then(console.log)
.catch(console.log);
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
}
});
And this to the app.json
file:
{
"expo": {
"name": "alhmp",
"slug": "alhmp",
"privacy": "public",
"sdkVersion": "33.0.0",
"platforms": ["ios", "android", "web"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/alhmp.png",
"resizeMode": "contain",
"backgroundColor": "#151515"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"infoPlist": {
"UIBackgroundModes": ["location", "fetch"]
}
}
}
}