- Add this to your dependencies in
package.json
:"react-native-begin-background-task": "git+https://github.com/blockfirm/react-native-begin-background-task.git"
- Run
npm install
- React Native 0.60+:
$ cd ios && pod install
React Native <0.60:$ react-native link react-native-begin-background-task
- Add this to your dependencies in
package.json
:"react-native-begin-background-task": "git+https://github.com/blockfirm/react-native-begin-background-task.git"
- Run
npm install
- 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)