How to use the react-native-background-fetch.FETCH_RESULT_NEW_DATA 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 / src / advanced / HomeView.tsx View on Github external
}, 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 BlueWallet / BlueWallet / models / notifications.js View on Github external
() => {
        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 => {
github textileio / photos / App / SDK / index.ts View on Github external
}
        await this.api.checkCafeMessages()
        await delay(ms / 2)
        if (cancelled) { // cancelled by event, so abort sequence
          foregroundEvent.remove() // remove our event listener
          break cancelSequence
        }
        // enter stopping sequence
        foregroundEvent.remove() // remove our event listener
        TextileEvents.stopNodeAfterDelayFinishing()
        await this.stopNode() // stop the node
        cancelled = true // be sure to exit the loop
    }

    await BackgroundTimer.stop()
    await BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA)
  }
}
github textileio / react-native-sdk / src / Textile / index.ts View on Github external
await API.cafes.checkMessages()
          await delay(ms / 2)
          if (cancelled) { // cancelled by event, so abort sequence
            foregroundEvent.remove() // remove our event listener
            break
          }
          // enter stopping sequence
          foregroundEvent.remove() // remove our event listener
          TextileEvents.stopNodeAfterDelayFinishing()
          await this.stopNode() // stop the node
          TextileEvents.stopNodeAfterDelayComplete()
          cancelled = true // be sure to exit the loop
      }
    } finally {
      // TODO: this might be better in a client provided callback
      await BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA)
      // Tells iOS that we are done with our background task so it's okay to suspend us
      await BackgroundTimer.stop()
    }
  }
}
github rastapasta / foodsharing / src / sagas / background.tsx View on Github external
function finish() {
  // Send an ackknowledge when we are done - required only by iOS
  if (Platform.OS === 'ios')
    BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA)
}
github textileio / photos / App / Sagas / NodeLifecycle.ts View on Github external
function * backgroundTaskRace () {
  // This race cancels whichever effect looses the race, so a foreground event will cancel stopping the node
  //
  // Using the race effect, if we get a foreground event while we're waiting
  // to stop the node, cancel the stop and let it keep running
  yield call(BackgroundTimer.start)
  yield race({
    delayAndStopNode: call(stopNodeAfterDelay, 20000),
    foregroundEvent: take(
      (action: RootAction) =>
        action.type === getType(TextileNodeActions.appStateChange) && action.payload.newState === 'active'
    )
  })
  yield all([
    call(BackgroundTimer.stop),
    call(BackgroundFetch.finish, BackgroundFetch.FETCH_RESULT_NEW_DATA)
  ])

}
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);
	}
};
github guardian / editions / projects / Mallard / src / helpers / push-download-failsafe.ts View on Github external
async () => {
            await pushTracking('backgroundFetch', 'started')
            await clearAndDownloadIssue()
            await pushTracking('backgroundFetch', 'ended')
            BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA)
        },
        error => {