Skip to content

djhr/react-native-background-execution-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-background-execution-iosios and add RCTBackgroundExecutionIOS.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRCTBackgroundExecutionIOS.a to your project's Build PhasesLink 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);

BackgroundExecutionIOS.beginBackgroundTask(onExpiration, onError);
//...
const remainingTime = await BackgroundExecutionIOS.backgroundTimeRemaining;
console.log(`Remaining background time: ${remainingTime}s`);
//...
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

About

React Native Background Execution Management for iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published