Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including react-native-background-execution-ios with all npm packages installed. Try it out:

var reactNativeBackgroundExecutionIos = require("react-native-background-execution-ios")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

react-native-background-execution-ios v1.0.0

React Native Background Execution Management for iOS

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);

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.

PropertyTypeNotes
backgroundTimeRemainingdoublereadonly

Methods

MethodArgumentsReturnNotes
beginBackgroundTaskonExpiration: function, onError: functionvoid
endBackgroundTaskvoidautomatically called in case of expiration
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free