rn-background-execution
v1.0.5
Published
Ensure that critical tasks finish when your app moves to the background
Downloads
6
Readme
rn-background-execution
This method requests additional background execution time for your app. Call this method when leaving a task unfinished might be detrimental to your app’s user experience. For example, call this method before writing data to a file to prevent the system from suspending your app while the operation is in progress.
Getting started
$ npm install rn-background-execution --save
Mostly automatic installation
$ react-native link rn-background-execution
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜rn-background-execution
and addRNBackgroundExecution.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNBackgroundExecution.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Usage
import RNBackgroundExecution from 'rn-background-execution';
// Mark the start of a task that should continue if the app enters the background.
RNBackgroundExecution.beginBackgroundTask().then((error) => {
// Callback after remaining background time expires.
});
// Marks the end of a specific long-running background task.
RNBackgroundExecution.endBackgroundTask();