Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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