How to use expo-background-fetch - 5 common examples

To help you get started, we’ve selected a few expo-background-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / apps / native-component-list / src / screens / BackgroundFetchScreen.tsx View on Github external
toggle = async () => {
    if (this.state.isRegistered) {
      await BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK);
    } else {
      await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
        minimumInterval: 60, // 1 minute
        stopOnTerminate: false,
        startOnBoot: true,
      });
    }
    this.setState({ isRegistered: !this.state.isRegistered });
  }
github expo / expo / apps / native-component-list / src / screens / BackgroundFetchScreen.tsx View on Github external
toggle = async () => {
    if (this.state.isRegistered) {
      await BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK);
    } else {
      await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
        minimumInterval: 60, // 1 minute
        stopOnTerminate: false,
        startOnBoot: true,
      });
    }
    this.setState({ isRegistered: !this.state.isRegistered });
  }
github expo / expo / apps / native-component-list / src / screens / BackgroundFetchScreen.tsx View on Github external
TaskManager.defineTask(BACKGROUND_FETCH_TASK, async () => {
  const now = Date.now();

  console.log(`Got background fetch call at date: ${new Date(now).toISOString()}`);
  await AsyncStorage.setItem(LAST_FETCH_DATE_KEY, now.toString());

  return BackgroundFetch.Result.NewData;
});
github expo / expo / apps / native-component-list / src / screens / BackgroundFetchScreen.tsx View on Github external
async checkStatusAsync() {
    const status = await BackgroundFetch.getStatusAsync();
    const isRegistered = await TaskManager.isTaskRegisteredAsync(BACKGROUND_FETCH_TASK);

    this.setState({ status, isRegistered });
  }

expo-background-fetch

Expo universal module for BackgroundFetch API

MIT
Latest version published 3 months ago

Package Health Score

92 / 100
Full package analysis