This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Expo TaskManager

A library that provides support for tasks that can run in the background.

Android
iOS
tvOS
Included in Expo Go
Recommended version:
~56.0.27

expo-task-manager provides an API that allows you to manage long-running tasks, in particular those tasks that can run while your app is in the background. Some features of this library are used by other libraries under the hood. Here is a list of Expo SDK libraries that use TaskManager.

Libraries using Expo TaskManager

Installation

Terminal
- npx expo install expo-task-manager
- yarn expo install expo-task-manager
- pnpm expo install expo-task-manager
- bun expo install expo-task-manager

If you are installing this in an existing React Native app, make sure to install expo in your project.


Configuration 
iOS

Standalone apps need some extra configuration: on iOS, each background feature requires a special key in UIBackgroundModes array in your Info.plist file.

Read more about how to configure this in the reference for each of the libraries that use TaskManager.

Usage

Example
import { Button, View, StyleSheet } from 'react-native'; import * as TaskManager from 'expo-task-manager'; import * as Location from 'expo-location'; const LOCATION_TASK_NAME = 'background-location-task'; const requestPermissions = async () => { const { status: foregroundStatus } = await Location.requestForegroundPermissionsAsync(); if (foregroundStatus === 'granted') { const { status: backgroundStatus } = await Location.requestBackgroundPermissionsAsync(); if (backgroundStatus === 'granted') { await Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, { accuracy: Location.Accuracy.Balanced, }); } } }; const PermissionsButton = () => ( <View style={styles.container}> <Button onPress={requestPermissions} title="Enable background location" /> </View> ); // Define the task at module scope so the background runtime can find it. // This needs to be called in the global scope, not in a React component. TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => { if (error) { // Error occurred - check `error.message` for more details. return; } if (data) { const { locations } = data; // do something with the locations captured in the background } }); const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, }); export default PermissionsButton;

API

import * as TaskManager from 'expo-task-manager';

No API data file found, sorry!