Skip to content

Latest commit

 

History

History
80 lines (62 loc) · 1.83 KB

INSTALL-EXPO.md

File metadata and controls

80 lines (62 loc) · 1.83 KB

Expo Setup

npx expo install react-native-background-fetch

📂 app.json

  • Add the following to plugins:
{
  "expo": {
    "name": "your-app-name",
    "plugins": [
+     "react-native-background-fetch"
    ]
  }
}
  • Add the following UIBackgroundModes and BGTaskSchedulerPermittedIdentifiers to the ios.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 the BGTaskSchedulerPermittedIdentifiers. For example, if you intend to execute a custom taskId: 'com.transistorsoft.customtask', you must add the identifier com.transistorsoft.customtask to BGTaskSchedulerPermittedIdentifiers:
  "BGTaskSchedulerPermittedIdentifiers": [
    "com.transistorsoft.fetch",
+   "com.transistorsoft.customtask"
  ]

⚠️ A task identifier can be any string you wish, but it's a good idea to prefix them now with 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)
});

Re-build

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