How to use the react-native-background-fetch.configure 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 jamesisaac / react-native-background-task / js / index.ios.js View on Github external
schedule: function(options = {}) {
    // Cancel existing tasks
    BackgroundFetch.stop()

    // Configure the native module
    // Automatically calls RNBackgroundFetch#start
    BackgroundFetch.configure(
      { stopOnTerminate: false },
      this._definition,
      () => {
        console.warn(`Background Fetch failed to start`)
      }
    )
  },
github transistorsoft / rn-background-geolocation-demo / src / advanced / HomeView.tsx View on Github external
configureBackgroundFetch() {
    // [Optional] Configure BackgroundFetch.
    BackgroundFetch.configure({
      minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed)
      stopOnTerminate: false, // <-- Android-only,
      startOnBoot: true, // <-- Android-only
      enableHeadless: true,
      requiresCharging: false,
      requiredNetworkType: BackgroundFetch.NETWORK_TYPE_NONE,
      requiresDeviceIdle: false,
      requiresBatteryNotLow: false,
      requiresStorageNotLow: false
    }, async () => {
      console.log('- BackgroundFetch start');
      let location = await BackgroundGeolocation.getCurrentPosition({persist: true, samples:1, extras: {'context': 'background-fetch-position'}});
      console.log('- BackgroundFetch current position: ', location) // <-- don't see this
      BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA);
    }, (error) => {
      console.log('[js] RNBackgroundFetch failed to start')
github transistorsoft / rn-background-geolocation-demo / components / HomeView.js View on Github external
componentDidMount() {
    //AppState.addEventListener('change', this.onAppStateChange.bind(this));

    this.setState({
      enabled: false
    });

    BackgroundFetch.configure({
      stopOnTerminate: false,
      minimumFetchInterval: 0
    }, () => {
      this.bgService.getPlugin().logger.ok('FETCH RECEIVED');
      BackgroundFetch.finish();
    }, (error) => {
      console.warn('Fetch error: ', error);
    });

    this.bgService.getState((state) => {
      this.configureBackgroundGeolocation(state);
    });

    // Fetch current app settings state.
    this.settingsService.getState((state) => {
      this.setState({
github BlueWallet / BlueWallet / models / notifications.js View on Github external
static configureBackgroundFetch() {
    BackgroundFetch.configure(
      {
        minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed)
        stopOnTerminate: false, // <-- Android-only,
        startOnBoot: true, // <-- Android-only
      },
      () => {
        console.log('[js] Received background-fetch event');
        // Required: Signal completion of your task to native code
        // If you fail to do this, the OS can terminate your app
        // or assign battery-blame for consuming too much background-time
        BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA);
      },
      error => {
        console.log('[js] RNBackgroundFetch failed to start');
        console.log(error);
      },
github textileio / photos / App / Services / EventHandlers / BackgroundFetchEventHandler.ts View on Github external
setup() {
    BackgroundFetch.configure(
      {},
      () => {
        this.store.dispatch(TriggersActions.backgroundFetch())
      },
      error => {
        // @todo - handle error
        console.info('backgroundFetch error')
      }
    )
  }
}
github guardian / editions / projects / Mallard / src / helpers / push-download-failsafe.ts View on Github external
const pushDownloadFailsafe = () => {
    BackgroundFetch.configure(
        {
            minimumFetchInterval: 120, // Every 2 hours
            stopOnTerminate: false,
            startOnBoot: true,
        },
        async () => {
            await pushTracking('backgroundFetch', 'started')
            await clearAndDownloadIssue()
            await pushTracking('backgroundFetch', 'ended')
            BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA)
        },
        error => {
            pushTracking('backgroundFetchError', error.toString())
        },
    )
github rdev / now-mobile / src / lib / background-task.js View on Github external
export default function setUpBackgroundTask() {
	BackgroundFetch.configure(
		{
			stopOnTerminate: false,
			startOnBoot: true,
			enableHeadless: true,
		},
		task,
		() => console.log('BACKGROUND TASK FAILED TO START'),
	);
}
github rastapasta / foodsharing / src / sagas / background.tsx View on Github external
return eventChannel(emitter => {
    BackgroundFetch.configure(configuration,
      () => emitter({type: BACKGROUND_WAKEUP}),
      (error) => emitter({type: BACKGROUND_ERROR, error})
    )

    return () => BackgroundFetch.stop()
  })
}