I have created an app that should always retrieve the geo-position of the user. Even if the app is in the background. I used react Expo’s TaskManager to do this. However, it doesn’t work at all on my emulator. Then I tried the Expo Go app on my android tablet. Here the geoposition is determined as long as the app is in the foreground. However, as soon as this is in the background, it stops tracking the geo position even though I have allowed every permission. I am using SDK 48.
Can someone help me with that?
TaskManager:
TaskManager.defineTask(TaskNames.BackgroundLocation, ({ data, error }) => {
if (error) {
console.error(error);
return;
}
if (data) {
const { locations } = data
console.log(locations);
}
});
startLocationUpdatesAsync:
if (this.backgroundStatus == 'granted') {
await Location.startLocationUpdatesAsync(taskName, {
accuracy: Location.Accuracy.BestForNavigation,
timeInterval: 1000,
// distanceInterval: 1,
activityType: Location.ActivityType.AutomotiveNavigation,
showsBackgroundLocationIndicator: true,
foregroundService: {
notificationTitle: "Text",
notificationBody: "Text",
notificationColor: "#RRGGBB",
},
});
}