Hey so the background fetch wont start on an iPad pro running iOS version 12.1.4, it works on iPhone 6, 7 and iPad 2018.
It gives this error message: [Unhandled promise rejection: Error: Background Location has not been configured. To enable it, add
locationto
UIBackgroundModes in Info.plist file.]
The info.plist file has the correct setup as it is working on other devices. The taskmanager is located in the app.js file, under the component.
export const startBackgroundFetch = () => (
async (dispatch) => {
dispatch(fetchLocationRequest());
const {Location, Permissions} = Expo;
// permissions returns only for location permissions on iOS and under certain conditions, see Permissions.LOCATION
const {status, permissions} = await Permissions.askAsync(Permissions.LOCATION);
if (status === 'granted') {
await Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, {
accuracy: Location.Accuracy.High,
timeInterval: 10000,
});
} else {
dispatch(fetchLocationError());
throw new Error('Location permission not granted');
}
}
);
TaskManager.defineTask(LOCATION_TASK_NAME, ({data, error}) => {
if (error) {
// Error occurred - check `error.message` for more details.
store.dispatch(fetchLocationError())
}
if (data) {
console.log('data', data);
let {locations} = data;
// do something with the locations captured in the background
if (!locations[0].coords.latitudeDelta) {
locations = {
latitude: locations[0].coords.latitude,
longitude: locations[0].coords.longitude,
latitudeDelta: 0.05,
longitudeDelta: 0.05,
}
}
const { carId, token } = store.getState().auth;
token && store.dispatch(updateCarPosition(locations, carId, token))
}
});