1.0.0 • Published 8 years ago
react-native-background-execution-ios v1.0.0
react-native-background-execution-ios
React Native Background Execution Management for iOS
Installation
yarn add react-native-background-execution-ios
Automatic linking
react-native link react-native-background-execution-ios
Manual linking
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-background-execution-ios➜iosand addRCTBackgroundExecutionIOS.xcodeproj - In XCode, in the project navigator, select your project. Add
libRCTBackgroundExecutionIOS.ato your project'sBuild Phases➜Link Binary With Libraries
Usage
import BackgroundExecutionIOS from 'react-native-background-execution-ios';
const onExpiration = (remainingTime) => console.info(`Background execution time will end in ${remainingTime}s`);
const onError = (err) => console.warn(err);
const backgroundTimeRemaining = await BackgroundExecutionIOS.backgroundTimeRemaining;
if (backgroundTimeRemaining > 0) {
BackgroundExecutionIOS.beginBackgroundTask(onExpiration, onError);
//...
BackgroundExecutionIOS.endBackgroundTask();
}API
Properties
Property getters return a promise resolved with the property value.
| Property | Type | Notes |
|---|---|---|
backgroundTimeRemaining | double | readonly |
Methods
| Method | Arguments | Return | Notes |
|---|---|---|---|
beginBackgroundTask | onExpiration: function, onError: function | void | |
endBackgroundTask | void | automatically called in case of expiration |
1.0.0
8 years ago