$ npm install --save react-native-background-fetch
📂 android/settings.gradle
+include ':react-native-background-fetch'
+project(':react-native-background-fetch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-fetch/android')
- 📂
android/build.gradle
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// Google now hosts their latest API dependencies on their own maven server.
// React Native will eventually add this to their app template.
+ maven {
+ url 'https://maven.google.com'
+ }
}
}
📂 android/app/build.gradle
+repositories {
+ flatDir {
+ dirs "../../node_modules/react-native-background-fetch/android/libs"
+ }
+}
dependencies {
+ compile project(':react-native-background-fetch')
+ compile(name: 'tsbackgroundfetch', ext: 'aar')
}
📂 android/app/main/java/com/.../MainApplication.java
+import com.transistorsoft.rnbackgroundfetch.RNBackgroundFetchPackage;
public class MainApplication extends ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
+ new RNBackgroundFetchPackage(),
new MainReactPackage()
);
}
}