How to use the react-native-background-fetch.registerHeadlessTask 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
// 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();
}


// Register your BackgroundFetch HeadlessTask
BackgroundFetch.registerHeadlessTask(BackgroundFetchHeadlessTask);
github rdev / now-mobile / index.js View on Github external
import { AppRegistry, YellowBox } from 'react-native';
import BackgroundFetch from 'react-native-background-fetch';
import App from './src/App';
import StorybookUI from './storybook';
import { task as BackgroundTask } from './src/lib/background-task';

YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);

const STORYBOOK = false;

AppRegistry.registerComponent('now', () => (__DEV__ && STORYBOOK ? StorybookUI : App));
BackgroundFetch.registerHeadlessTask(BackgroundTask);