$ npm install react-native-begin-background-task --save
$ react-native link react-native-begin-background-task
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-begin-background-task
and addRNBeginBackgroundTask.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNBeginBackgroundTask.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
import { beginBackgroundTask, endBackgroundTask } from 'react-native-begin-background-task';
// ...
const backgroundTaskId = await beginBackgroundTask();
// ...
await endBackgroundTask(backgroundTaskId)