startLocationUpdateAsync is not working on iPad pro running iOS 12.1.4

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, addlocationtoUIBackgroundModesin 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))
    }
});
1 Like

Hey @napapp, could you open up a GH issue here for this? Not sure why this would work for all the other devices, but not for that particular one.

Hey @napapp,

Sorry I didn’t link this before- but background location has been removed from the Expo client. So if this is on the Expo client and not a standalone app, you can follow the instructions there to work around it.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.