How to use the react-native-background-fetch.finish function in react-native-background-fetch

To help you get started, we’ve selected a few react-native-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 transistorsoft / rn-background-geolocation-demo / index.js View on Github external
let BackgroundFetchHeadlessTask = async (event) => {
  console.log('[BackgroundFetch HeadlessTask] start');
  // Important:  await asychronous tasks when using HeadlessJS.
  /* DISABLED
  let location = await BackgroundGeolocation.getCurrentPosition({persist: false, samples: 1});
  console.log('- current position: ', location);
  // Required:  Signal to native code that your task is complete.
  // If you don't do this, your app could be terminated and/or assigned
  // battery-blame for consuming too much time in background.
  */
  console.log('[BackgroundFetch HeadlessTask] finished');

  BackgroundFetch.finish();
}
github transistorsoft / rn-background-geolocation-demo / components / HomeView.js View on Github external
}, () => {
      this.bgService.getPlugin().logger.ok('FETCH RECEIVED');
      BackgroundFetch.finish();
    }, (error) => {
      console.warn('Fetch error: ', error);
github rdev / now-mobile / src / lib / background-task.js View on Github external
export const task = async () => {
	console.log('BACKGROUND TASK STARTING');

	const { deployments, error: deploymentsError } = await api.deployments();
	const usage = await api.usage();

	if (deploymentsError || usage.error) {
		console.log('BACKGROUND TASK ERROR', deploymentsError, usage.error);
		BackgroundFetch.finish();
	} else {
		await saveDeployments(deployments);
		await saveUsage(usage);
		await notifyIfAppropriate(usage);

		console.log('BACKGROUND TASK DONE');
		BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA);
	}
};