$ yarn add react-native-background-fetch$ npm install --save react-native-background-fetchThe SDK requires a custom maven url in the root android/build.gradle:
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
+ maven {
+ // react-native-background-fetch
+ url("${project(':react-native-background-fetch').projectDir}/libs")
+ }
}
}If you're using minifyEnabled true with your Android release build, the plugin's HeadlessTask class will be mistakenly removed and you will have this crash.
- Edit
android/app/proguard-rules.pro. - Add the following rule:
# [react-native-background-fetch]
-keep class com.transistorsoft.rnbackgroundfetch.HeadlessTask { *; }