diff --git a/App/managers/AqiHistoryTask.ts b/App/managers/AqiHistoryTask.ts index bd216f71..6787556f 100644 --- a/App/managers/AqiHistoryTask.ts +++ b/App/managers/AqiHistoryTask.ts @@ -60,5 +60,8 @@ defineTask(AQI_HISTORY_TASK, () => { }, () => T.of(Result.NewData) ) - )().catch(logFpError); + )().catch(error => { + logFpError(error); + return Result.Failed; + }); }); diff --git a/App/stores/fetchGpsPosition/fetchGpsPosition.ts b/App/stores/fetchGpsPosition/fetchGpsPosition.ts index 13a003a5..4a88c8f6 100644 --- a/App/stores/fetchGpsPosition/fetchGpsPosition.ts +++ b/App/stores/fetchGpsPosition/fetchGpsPosition.ts @@ -81,14 +81,15 @@ export function fetchGpsPosition () { // Start the task to record periodically on the background the location const isAqiRegistered = await isTaskRegisteredAsync(AQI_HISTORY_TASK); if (!isAqiRegistered) { - BackgroundFetch.registerTaskAsync(AQI_HISTORY_TASK, { + await BackgroundFetch.registerTaskAsync(AQI_HISTORY_TASK, { minimumInterval: SAVE_DATA_INTERVAL, // in s startOnBoot: true, stopOnTerminate: false }); - // Apparently this is needed on iOS + // Apparently this is needed // https://github.com/expo/expo/issues/3582#issuecomment-480924126 - BackgroundFetch.setMinimumIntervalAsync(SAVE_DATA_INTERVAL); + // https://github.com/expo/expo/issues/3582#issuecomment-520035731 + await BackgroundFetch.setMinimumIntervalAsync(SAVE_DATA_INTERVAL); } return ExpoLocation.getCurrentPositionAsync({