Skip to content
Open
Show file tree
Hide file tree
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
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

The Geolocation API 📍 module for React Native that extends the [Geolocation web spec](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation).

**This fork adds support for background location updates, allowing your app to receive location updates even when it's not in the foreground.**

Supports TurboModules ⚡️ and legacy React Native architecture.

Fully compatible with TypeScript.
Expand Down Expand Up @@ -32,11 +34,15 @@ Supports modern [Play Services Location API](https://developers.google.com/andro

## Getting started

`yarn add @react-native-community/geolocation`
This is a fork of the original `@react-native-community/geolocation` package.

To install this forked version:

`yarn add https://github.com/quan118/react-native-geolocation`

or

`npm install @react-native-community/geolocation --save`
`npm install https://github.com/quan118/react-native-geolocationn --save`

## Configuration and Permissions

Expand Down Expand Up @@ -70,6 +76,15 @@ or

`<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />`


To enable background location updates, add the following permissions:

```xml
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
```

Android API >= 18 Positions will also contain a `mocked` boolean to indicate if position was created from a mock provider.

<p>
Expand Down Expand Up @@ -181,7 +196,7 @@ Supported options:

* `skipPermissionRequests` (boolean) - Defaults to `false`. If `true`, you must request permissions before using Geolocation APIs.
* `authorizationLevel` (string, iOS-only) - Either `"whenInUse"`, `"always"`, or `"auto"`. Changes whether the user will be asked to give "always" or "when in use" location services permission. Any other value or `auto` will use the default behaviour, where the permission level is based on the contents of your `Info.plist`.
* `enableBackgroundLocationUpdates` (boolean, iOS-only) - When using `skipPermissionRequests`, toggle wether to automatically enableBackgroundLocationUpdates. Defaults to true.
* `enableBackgroundLocationUpdates` (boolean) - When using `skipPermissionRequests`, toggle wether to automatically enableBackgroundLocationUpdates. Defaults to true.
* `locationProvider` (string, Android-only) - Either `"playServices"`, `"android"`, or `"auto"`. Determines wether to use `Google’s Location Services API` or `Android’s Location API`. The `"auto"` mode defaults to `android`, and falls back to Android's Location API if play services aren't available.

---
Expand Down
8 changes: 7 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactnativecommunity.geolocation">

<application>
<service
android:name=".LocationService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="location" />
</application>
</manifest>

Loading