Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toggle = async () => {
if (this.state.isRegistered) {
await BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK);
} else {
await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, {
minimumInterval: 60, // 1 minute
stopOnTerminate: false,
startOnBoot: true,
});
}
this.setState({ isRegistered: !this.state.isRegistered });
}