How to use the react-native-background-fetch.NETWORK_TYPE_ANY 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 rastapasta / foodsharing / src / sagas / background.tsx View on Github external
import BackgroundFetch from 'react-native-background-fetch'

import {
  LOGIN_SUCCESS,
  LOGOUT,
  BACKGROUND_WAKEUP,
  BACKGROUND_DONE,
  BACKGROUND_ERROR,
  CONVERSATIONS_REQUEST
} from '../common/constants'

const configuration = {
  minimumFetchInterval: 15,
  startOnBoot: true,
  stopOnTerminate: false,
  requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY
}

// Build an event channel around the background task notifier
function start() {
  return eventChannel(emitter => {
    BackgroundFetch.configure(configuration,
      () => emitter({type: BACKGROUND_WAKEUP}),
      (error) => emitter({type: BACKGROUND_ERROR, error})
    )

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

function finish() {
  // Send an ackknowledge when we are done - required only by iOS