npx expo install react-native-background-fetch
- Add the following to
plugins
:
{
"expo": {
"name": "your-app-name",
"plugins": [
+ "react-native-background-fetch"
]
}
}
- Add the following
UIBackgroundModes
andBGTaskSchedulerPermittedIdentifiers
to theios.infoPlist
section:
{
"expo": {
"name": "your-app-name",
"plugins": [
"react-native-background-fetch"
],
"ios": {
+ "infoPlist": {
+ "UIBackgroundModes": [
+ "fetch",
+ "processing"
+ ],
+ "BGTaskSchedulerPermittedIdentifiers": [
+ "com.transistorsoft.fetch"
+ ]
+ }
}
}
}
- If you intend to execute your own custom tasks via
BackgroundFetch.scheduleTask
, you must add those custom identifiers as well to theBGTaskSchedulerPermittedIdentifiers
. For example, if you intend to execute a customtaskId: 'com.transistorsoft.customtask'
, you must add the identifiercom.transistorsoft.customtask
toBGTaskSchedulerPermittedIdentifiers
:
"BGTaskSchedulerPermittedIdentifiers": [
"com.transistorsoft.fetch",
+ "com.transistorsoft.customtask"
]
com.transistorsoft.
— In the future, the com.transistorsoft
prefix may become required.
BackgroundFetch.scheduleTask({
taskId: 'com.transistorsoft.customtask',
delay: 60 * 60 * 1000 // In one hour (milliseconds)
});
You must rebuild your Android app for the added plugins to be evaluated.
- If you're developing locally:
npx expo prebuild
- If you're using Expo EAS:
eas build --profile development --platform android