Skip to content

Update docs for better understanding of where to add the dependency #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions docs/INSTALL-AUTO-ANDROID.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,46 @@ $ yarn add react-native-background-fetch
```

### With `npm`

```bash
$ npm install --save react-native-background-fetch
```

## Gradle Configuration

The SDK requires a custom __`maven url`__ in the root __`android/build.gradle`__.
Please note that some more recent versions of React Native the Android template may not include __`allprojects`__ section. You should add this manually as a separate section along with the nested __`repositories`__ section in the same __`android/build.gradle`__ file.
The SDK requires a custom **`maven url`** in the root **`android/build.gradle`**.
Please note that some more recent versions of React Native the Android template may not include **`allprojects`** section. You should add this manually as a separate section along with the nested **`repositories`** section in the same **`android/build.gradle`** file. Please note that the `allProjects` needs to be added in the `buildscript` section and not as a separate section, in order to work with the Android template.

### :open_file_folder: **`android/build.gradle`**

```diff
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")
+ }
buildscript {
// other build scripts, ext, repositories, etc.

+ 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")
+ }

}
}
}
```

## Precise event-scheduling with `forceAlarmManager: true`:

**Only** If you wish to use precise scheduling of events with __`forceAlarmManager: true`__, *Android 14 (SDK 34)*, has restricted usage of ["`AlarmManager` exact alarms"](https://developer.android.com/about/versions/14/changes/schedule-exact-alarms). To continue using precise timing of events with *Android 14*, you can manually add this permission to your __`AndroidManifest`__. Otherwise, the plugin will gracefully fall-back to "*in-exact* `AlarmManager` scheduling":
**Only** If you wish to use precise scheduling of events with **`forceAlarmManager: true`**, _Android 14 (SDK 34)_, has restricted usage of ["`AlarmManager` exact alarms"](https://developer.android.com/about/versions/14/changes/schedule-exact-alarms). To continue using precise timing of events with _Android 14_, you can manually add this permission to your **`AndroidManifest`**. Otherwise, the plugin will gracefully fall-back to "_in-exact_ `AlarmManager` scheduling":

:open_file_folder: In your `AndroidManifest`, add the following permission (**exactly as-shown**):

Expand All @@ -55,5 +60,5 @@ allprojects {
.
</manifest>
```
:warning: It has been announced that *Google Play Store* [has plans to impose greater scrutiny](https://support.google.com/googleplay/android-developer/answer/13161072?sjid=3640341614632608469-NA) over usage of this permission (which is why the plugin does not automatically add it).

:warning: It has been announced that _Google Play Store_ [has plans to impose greater scrutiny](https://support.google.com/googleplay/android-developer/answer/13161072?sjid=3640341614632608469-NA) over usage of this permission (which is why the plugin does not automatically add it).