I have an EAS stand alone app that was built using Expo SDK 50. I am trying to access a user’s background location (location when the app is not open but running in the background)
When i test the app by expo go it work well, ask the permissions and access to user location.
but on test the build apk, the access to user location not succeed.
app.json:
{
"expo":{
"plugins": [
[
"expo-location",
{
"locationAlwaysAndWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location.",
}
]
],
"android": {
"permissions": [
"ACCESS_COARSE_LOCATION",
"ACCESS_FINE_LOCATION",
"ACCESS_BACKGROUND_LOCATION"
]
},
}
index.tsx:
const trackUserLocation = async () => {
try {
const { status: foregroundStatus } = await Location.requestForegroundPermissionsAsync();
const { status: backgroundStatus } = await Location.requestBackgroundPermissionsAsync();
if (backgroundStatus !== 'granted'|| foregroundStatus !== 'granted') {
Alert.alert('notice','no permissions for track location')
return;
}
let isRegister = await TaskManager.isTaskRegisteredAsync(LOCATION_TASK_NAME);
if (isRegister)
return;
await Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, {
accuracy: Location.Accuracy.BestForNavigation,
timeInterval: 30 * 1000,
foregroundService: {
notificationTitle: 'location tracking',
notificationBody: 'track your location',
notificationColor: '#FBC02D',
},
});
}
catch (e) {
console.log(e);
}
}
is see in expo docs that they add permissions like this
{
"expo":{
"android": {
"permissions": [
"android.permission.ACCESS_COARSE_LOCATION",
"android.permission.ACCESS_FINE_LOCATION",
"android.permission.ACCESS_BACKGROUND_LOCATION"
]
},
}
but all of the code example use the short way
so, what can cause that