SDK Version: latest
Platforms: iOS
I’m using a bare React Native app, I’m able to start the task and receive updates in the foreground. Once the app is moved to the background, it runs for ~1 minute, then stops retrieving location data. When running in Xcode, I receive an error ‘Terminated due to signal 9’.
Relevant code
await Location.startLocationUpdatesAsync('background-location', {
accuracy: Location.Accuracy.Highest,
timeInterval: 5000,
distanceInterval: 0,
});
TaskManager.defineTask('background-location', async ({ data, error }) => {
var id = await AsyncStorage.getItem('id');
console.log('id: ', id);
if (id === '')
return;
console.log('Retrieving Location');
if (error) {
alert(error)
// Error occurred - check `error.message` for more details.
return;
}
if (data) {
const { locations } = data;
await AsyncStorage.setItem('location', JSON.stringify(locations[0]));
// lat is locations[0].coords.latitude & long is locations[0].coords.longitude
}
});