Skip to content

Commit

Permalink
chore: Update README.md for android setup running on React Native 0.6…
Browse files Browse the repository at this point in the history
…5 and bellow (#259)

* Update README.md

* Add new information as collapsible
  • Loading branch information
BenHurMartins authored Jul 21, 2023
1 parent 24a026e commit 72acc05
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,40 @@ Android API >= 18 Positions will also contain a `mocked` boolean to indicate if
Failure to do so may result in a hard crash.
</p>

<details>
<summary><b>For React Native < 0.65 on Android we need to link manually</b></summary>


- android/settings.gradle
```
include ':react-native-community-geolocation'
project(':react-native-community-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/geolocation/android')
```
- android/app/build.gradle
```
dependencies {
...
implementation project(':react-native-community-geolocation')
}
```
- android/app/src/main/.../MainApplication.java
On imports section:
```java
import com.reactnativecommunity.geolocation.GeolocationPackage;
```
In the class at `getPackages` method:
```java
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
packages.add(new GeolocationPackage()); // <== add this line
return packages;
}
```
</details>

## Migrating from the core `react-native` module
This module was created when the Geolocation was split out from the core of React Native. As a browser polyfill, this API was available through the `navigator.geolocation` global - you didn't need to import it. To migrate to this module you need to follow the installation instructions above and change following code:

Expand Down

0 comments on commit 72acc05

Please sign in to comment.