{"id":4570,"url":"https://github.com/timfpark/react-native-location","last_synced_at":"2025-05-15T03:02:54.694Z","repository":{"id":33316744,"uuid":"36961486","full_name":"timfpark/react-native-location","owner":"timfpark","description":"React Native plug-in that provides GPS location information","archived":false,"fork":false,"pushed_at":"2024-04-17T21:16:14.000Z","size":5131,"stargazers_count":886,"open_issues_count":112,"forks_count":209,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-02T09:45:29.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timfpark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-06T00:20:31.000Z","updated_at":"2025-03-20T11:21:09.000Z","dependencies_parsed_at":"2024-01-08T01:03:36.504Z","dependency_job_id":"7ac162c7-6d9b-46b6-b855-fd58c9edf025","html_url":"https://github.com/timfpark/react-native-location","commit_stats":{"total_commits":151,"total_committers":20,"mean_commits":7.55,"dds":"0.35761589403973515","last_synced_commit":"086912ea03b43d0507a26123ca51f597518d5042"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timfpark%2Freact-native-location","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timfpark%2Freact-native-location/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timfpark%2Freact-native-location/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timfpark%2Freact-native-location/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timfpark","download_url":"https://codeload.github.com/timfpark/react-native-location/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166857,"owners_count":21058481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:16.570Z","updated_at":"2025-04-10T06:16:59.080Z","avatar_url":"https://github.com/timfpark.png","language":"JavaScript","readme":"# `react-native-location`\n\n![MIT License](https://img.shields.io/npm/l/react-native-location.svg) ![Supports Android and iOS](https://img.shields.io/badge/platforms-android%20|%20ios-lightgrey.svg) ![Supports React Native \u003e= 0.46](https://img.shields.io/badge/react%20native-%3E%3D%200.46-lightgrey.svg) [![CircleCI Status](https://img.shields.io/circleci/project/github/timfpark/react-native-location/master.svg)](https://circleci.com/gh/timfpark/workflows/react-native-location/tree/master)\n\nNative GPS location support for React Native. You might decide to use this library over the [built-in geolocation](https://facebook.github.io/react-native/docs/geolocation.html) because it includes some additional features:\n\n* Allows you choose what type of permission to ask for (\"when in use\" or \"always\"). The built-in geolocation library will look at your plist file and choose \"always\" if you have the `NSLocationAlwaysUsageDescription` property, however, you might have a usecase where you want to start by asking the user for \"while in use\" permission and later upgrade the permission to \"always\" when they turn on a feature which requires background location.\n* Ability to check the current permission status (`RNLocation.getCurrentPermission`).\n* Allows you to monitor the device heading.\n\n## Installation\nInstall the library using either Yarn:\n\n```\nyarn add react-native-location\n```\n\nor using npm:\n\n```\nnpm install --save react-native-location\n```\n\nYou then need to link the native parts of the library for the platforms you are using. Click on the arrow to show the steps for each platform.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eiOS Installation Instructions\u003c/strong\u003e\u003c/summary\u003e\n\n### 1a. Automatically link with the CLI tool\nThe easiest way to link the library is using the CLI tool by running this command from the root of your project:\n\n```\nreact-native link react-native-location\n```\n\n### 1b. Install with Cocoapods\nYou can also link the library using Cocoapods by adding this line to your `Podfile`:\n\n```ruby\npod 'react-native-location', :path =\u003e '../node_modules/react-native-location/react-native-location.podspec'\n```\n\n### 1c. Or manually link the library\nIf you can't or don't want to use the CLI tool, you can also manually link the library using the [intructions in the React NAtive documentation](https://facebook.github.io/react-native/docs/linking-libraries-ios#manual-linking).\n\n### 2. Ensure you have the CoreLocation library linked\n*This is not required if you have installed using Cocoapods.*\n\nYou then need to make sure you have the iOS CoreLocation library linked to your project.\n\nTo do this, click on the your project in XCode (the name of your project at the top of the left panel), select your apps build target, go to the `Build Phases` tab then in the `Link Binary With Libraries` section add `CoreLocation.framework`.\n\n### 3. Info.plist usage descriptions\nFinally, you then need to make sure you have the correct usage discriptions inside your `Info.plist` file. The message will show in the Alert box when your app requests permissions and lets the user know why you are asking for that permissions. They are also part of the App Store review process.\n\nIf you are only requesting \"when in use\" (foreground) location access you just need to make sure you have the `NSLocationWhenInUseUsageDescription` item in your Plist.\n\nIf you are requesting \"always\" (background) permission you will *also* need to add `NSLocationAlwaysAndWhenInUseUsageDescription` and `NSLocationAlwaysUsageDescription` into your PList file.\n\nThe easiest way to add these is to find your `Info.plist` in Xcode, right click on it, and then choose \"edit as source code\". You can then enter the items you need into the file:\n\n```xml\n\u003ckey\u003eNSLocationWhenInUseUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis is the plist item for NSLocationWhenInUseUsageDescription\u003c/string\u003e\n\u003ckey\u003eNSLocationAlwaysAndWhenInUseUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis is the plist item for NSLocationAlwaysAndWhenInUseUsageDescription\u003c/string\u003e\n\u003ckey\u003eNSLocationAlwaysUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis is the plist item for NSLocationAlwaysUsageDescription\u003c/string\u003e\n```\n\n### 4. Background mode setup (optional)\nFor background location to work, a few things need to be configured:\n\n1. In the Xcode project, go to Capabilities, switch on \"Background Modes\" and check \"Location updates\".\n2. Set `NSLocationAlwaysAndWhenInUseUsageDescription` and `NSLocationAlwaysUsageDescription` in your `Info.plist` file.\n3. For iOS 9+, set [`allowsBackgroundLocationUpdates`](https://developer.apple.com/reference/corelocation/cllocationmanager/1620568-allowsbackgroundlocationupdates) to true when configuring the library in your Javascript code. Like this:\n\n```javascript\nRNLocation.configure({ allowsBackgroundLocationUpdates: true });\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eAndroid Installation Instructions\u003c/strong\u003e\u003c/summary\u003e\n\n### 1a. Automatically link the library using the CLI tool\nThe easiest way to link the library is using the CLI tool by running this command from the root of your project:\n\n```\nreact-native link react-native-location\n```\n\n### 1b. Manually link the library\nIf you can't or don't want to use the CLI tool, you can manually link the library by making the following changes (click on the arrow to show the steps):\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eSteps to manually link the library\u003c/strong\u003e\u003c/summary\u003e\n   \n#### `android/settings.gradle`\n```groovy\ninclude ':react-native-location'\nproject(':react-native-location').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-location/android')\n```\n\n#### `android/app/build.gradle`\n```groovy\ndependencies {\n   ...\n   implementation project(':react-native-location')\n}\n```\n\n#### `android/app/src/main/.../MainApplication.java`\nOn top, where imports are:\n\n```java\nimport com.github.reactnativecommunity.location.RNLocationPackage;\n```\n\nAdd the `RNLocationPackage` class to your list of exported packages.\n\n```java\n@Override\nprotected List\u003cReactPackage\u003e getPackages() {\n    return Arrays.asList(\n            new MainReactPackage(),\n            new RNLocationPackage()\n    );\n}\n```\n\u003c/details\u003e\n\n### 2. Android manifest permissions\nYou need to ensure that your `AndroidManifest.xml` contains this line:\n\n```xml\n\u003cuses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/\u003e\n```\n\nIf you want to access fine location then you should also include:\n\n```xml\n\u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/\u003e\n```\n\n### 3. Install the Google Fused Location provider dependency (optional)\nThe library provides two methods of getting the location on Android. The default is the builtin location manager, however, you can optionally choose to install the Fused Location library which provides more accurate and faster results. The downside is that it will only work on devices with Google Play Services installed and configured (which is most Android devices in the west, but not Kindle devices or Asian markets).\n\nIf you would like to use the Google Play Services Fused Location provider, then you need to add these dependencies to your `android/app/build.gradle` file:\n\n```groovy\nimplementation \"com.google.android.gms:play-services-base:16.0.1\"\nimplementation \"com.google.android.gms:play-services-location:16.0.0\"\n```\n\u003c/details\u003e\n\n## Example application\nIn the [example](https://github.com/timfpark/react-native-location/example) folder is a React Native sample app which you can use as a sample implementation to start from.\n\nThe app requests permissions, takes reading every 5 distance and starts immediately. To use in the iOS simulator, look on the `Debug -\u003e Location` menu for sample trips that will show you updating location such as City Bycicle Ride, City Run, and Freeway Drive.\n\n![Example App](./screenshots/example.gif)\n\n## Usage\n```javascript\nimport RNLocation from 'react-native-location';\n\nRNLocation.configure({\n  distanceFilter: 5.0\n})\n\nRNLocation.requestPermission({\n  ios: \"whenInUse\",\n  android: {\n    detail: \"coarse\"\n  }\n}).then(granted =\u003e {\n    if (granted) {\n      this.locationSubscription = RNLocation.subscribeToLocationUpdates(locations =\u003e {\n        /* Example location returned\n        {\n          speed: -1,\n          longitude: -0.1337,\n          latitude: 51.50998,\n          accuracy: 5,\n          heading: -1,\n          altitude: 0,\n          altitudeAccuracy: -1\n          floor: 0\n          timestamp: 1446007304457.029,\n          fromMockProvider: false\n        }\n        */\n      })\n    }\n  })\n```\n\n## Methods\nTo access the methods, you need import the `react-native-location` module. This is done through `import RNLocation from 'react-native-location'`.\n\n### Configuration\n#### `RNLocation.configure`\nThis is used to configure the location provider. You can use this to enable background mode, filter location updates to a certain distance change, and ensure you have the power settings set correctly for your use case.\n\nYou can call `configure` multiple times at it will only change the setting which you pass to it. For example if you only want to change `activityType`, you can call `configure` with just that property present.\n\n```javascript\nRNLocation.configure({\n    distanceFilter: 100, // Meters\n    desiredAccuracy: {\n      ios: \"best\",\n      android: \"balancedPowerAccuracy\"\n    },\n    // Android only\n    androidProvider: \"auto\",\n    interval: 5000, // Milliseconds\n    fastestInterval: 10000, // Milliseconds\n    maxWaitTime: 5000, // Milliseconds\n    // iOS Only\n    activityType: \"other\",\n    allowsBackgroundLocationUpdates: false,\n    headingFilter: 1, // Degrees\n    headingOrientation: \"portrait\",\n    pausesLocationUpdatesAutomatically: false,\n    showsBackgroundLocationIndicator: false,\n})\n```\n\nThere are the valid configuration options and what they do:\n\n\u003ctable\u003e\n   \u003ctr\u003e\n      \u003cth\u003eOption\u003c/th\u003e\n      \u003cth\u003ePlatforms\u003c/th\u003e\n      \u003cth\u003eDescription\u003c/th\u003e\n      \u003cth\u003eValues\u003c/th\u003e\n      \u003cth\u003eDocumentation\u003c/th\u003e\n   \u003c/tr\u003e\n   \n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003edistanceFilter\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n         Android\n         iOS\n      \u003c/td\u003e\n      \u003ctd\u003eThe minimum distance in meters that the device location needs to change before the location update callback in your app is called. Defaults to \u003ccode\u003e0\u003c/code\u003e for no filtering.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        \u003ca href=\"https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setSmallestDisplacement(float)\"\u003eAndroid Docs\u003c/a\u003e\n        \u003ca href=\"https://developer.apple.com/documentation/corelocation/cllocationmanager/1423500-distancefilter\"\u003eApple Docs\u003c/a\u003e\n      \u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003edesiredAccuracy\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\n         Android\n         iOS\n      \u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eThe accuracy of the location data. Defaults to \u003ccode\u003ebest\u003c/code\u003e on iOS and \u003ccode\u003ebalancedPowerAccuracy\u003c/code\u003e on Android.\u003c/p\u003e\n        \u003cp\u003eValid options for \u003ccode\u003eandroid\u003c/code\u003e: \u003ccode\u003ebalancedPowerAccuracy\u003c/code\u003e, \u003ccode\u003ehighAccuracy\u003c/code\u003e, \u003ccode\u003elowPower\u003c/code\u003e, or \u003ccode\u003enoPower\u003c/code\u003e.\u003c/p\u003e\n        \u003cp\u003eValid options for \u003ccode\u003eios\u003c/code\u003e: \u003ccode\u003ebestForNavigation\u003c/code\u003e, \u003ccode\u003ebest\u003c/code\u003e, \u003ccode\u003enearestTenMeters\u003c/code\u003e, \u003ccode\u003ehundredMeters\u003c/code\u003e, or \u003ccode\u003ethreeKilometers\u003c/code\u003e.\u003c/p\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\n        \u003ccode\u003e{ android: string, ios: string }\u003c/code\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\n        \u003ca href=\"https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#setPriority(int)\"\u003eAndroid Docs\u003c/a\u003e\n        \u003ca href=\"https://developer.apple.com/documentation/corelocation/cllocationaccuracy?language=objc\"\u003eApple Docs\u003c/a\u003e\n      \u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eandroidProvider\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eAndroid\u003c/td\u003e\n      \u003ctd\u003eThe provider which is used on Android to get the location. Your app must include the Google Play services dependencies to use the \u003ccode\u003eplayServices\u003c/code\u003e location provider. By default it will choose the \u003ccode\u003eplayServices\u003c/code\u003e location provider if it detects that the dependencies are installed, otherwise, it will use the \u003ccode\u003estandard\u003c/code\u003e Android version which does not require Google Play Services to be installed. Note that \u003ccode\u003eauto\u003c/code\u003e only checks that the dependencies are installed, not that the user has the Google Play services APK installed and set up correctly.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\"auto\"\u003c/code\u003e, \u003ccode\u003e\"playServices\"\u003c/code\u003e, or \u003ccode\u003e\"standard\"\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eAndroid\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eSet the desired interval for active location updates, in milliseconds.\u003c/p\u003e\n        \u003cp\u003eThe location client will actively try to obtain location updates for your application at this interval, so it has a direct influence on the amount of power used by your application. Choose your interval wisely.\u003c/p\u003e\n        \u003cp\u003eThis interval is inexact. You may not receive updates at all (if no location sources are available), or you may receive them slower than requested. You may also receive them faster than requested (if other applications are requesting location at a faster interval).\u003c/p\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#setInterval(int)\"\u003eAndroid Docs\u003c/a\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003efastestInterval\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eAndroid\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eExplicitly set the fastest interval for location updates, in milliseconds.\u003c/p\u003e\n        \u003cp\u003eThis controls the fastest rate at which your application will receive location updates, which might be faster than `interval` in some situations (for example, if other applications are triggering location updates).\u003c/p\u003e\n        \u003cp\u003eThis allows your application to passively acquire locations at a rate faster than it actively acquires locations, saving power.\u003c/p\u003e\n        \u003cp\u003eBy default this is 6x the `interval`.\u003c/p\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#setFastestInterval(int)\"\u003eAndroid Docs\u003c/a\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n   \n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003emaxWaitTime\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eAndroid\u003c/td\u003e\n      \u003ctd\u003e\n        \u003cp\u003eSets the maximum wait time in milliseconds for location updates.\u003c/p\u003e\n        \u003cp\u003eIf you pass a value at least 2x larger than the interval specified with setInterval(long), then location delivery may be delayed and multiple locations can be delivered at once.\u003c/p\u003e\n      \u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest#setMaxWaitTime(int)\"\u003eAndroid Docs\u003c/a\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eallowsBackgroundLocationUpdates\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eiOS\u003c/td\u003e\n      \u003ctd\u003eA Boolean value indicating whether the app should receive location updates when suspended. Requires permissions to always access the users location. Defaults to \u003ccode\u003efalse\u003c/code\u003e.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://developer.apple.com/documentation/corelocation/cllocationmanager/1620568-allowsbackgroundlocationupdates\"\u003eApple Docs\u003c/a\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eactivityType\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eiOS\u003c/td\u003e\n      \u003ctd\u003eThe type of user activity associated with the location updates. Defaults to \u003ccode\u003eother\u003c/code\u003e.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\"other\"\u003c/code\u003e, \u003ccode\u003e\"automotiveNavigation\"\u003c/code\u003e, \u003ccode\u003e\"fitness\"\u003c/code\u003e, \u003ccode\u003e\"otherNavigation\"\u003c/code\u003e, or \u003ccode\u003e\"airborne\"\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://developer.apple.com/documentation/corelocation/cllocationmanager/1620567-activitytype\"\u003eApple Docs\u003c/a\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eheadingFilter\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eiOS\u003c/td\u003e\n      \u003ctd\u003eThe minimum angle in degrees that the device heading needs to change before the heading update callback in your app is called. Defaults to \u003ccode\u003e0\u003c/code\u003e for no filtering.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003enumber\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eheadingOrientation\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eiOS\u003c/td\u003e\n      \u003ctd\u003eThe device orientation to use when computing heading values. Defaults to \u003ccode\u003eportrait\u003c/code\u003e.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003e\"portrait\"\u003c/code\u003e, \u003ccode\u003e\"portraitUpsideDown\"\u003c/code\u003e, \u003ccode\u003e\"landscapeLeft\"\u003c/code\u003e, or \u003ccode\u003e\"landscapeRight\"\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://developer.apple.com/documentation/corelocation/cllocationmanager/1620556-headingorientation\"\u003eApple Docs\u003c/a\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003epausesLocationUpdatesAutomatically\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eiOS\u003c/td\u003e\n      \u003ctd\u003eA Boolean value indicating whether the location manager object may pause location updates. Defaults to \u003ccode\u003etrue\u003c/code\u003e.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://developer.apple.com/documentation/corelocation/cllocationmanager/1620553-pauseslocationupdatesautomatical\"\u003eApple Docs\u003c/a\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ccode\u003eshowsBackgroundLocationIndicator\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eiOS\u003c/td\u003e\n      \u003ctd\u003eA Boolean indicating whether the status bar changes its appearance when location services are used in the background. Defaults to \u003ccode\u003efalse\u003c/code\u003e. Only works on iOS 11+ and is ignored for earlier versions of iOS.\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003eboolean\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ca href=\"https://developer.apple.com/documentation/corelocation/cllocationmanager/2923541-showsbackgroundlocationindicator\"\u003eApple Docs\u003c/a\u003e\u003c/td\u003e\n   \u003c/tr\u003e\n\u003c/table\u003e\n\n### Permissions\nCorrectly managing permissions is key to working with the users location in mobile apps.\n\n* Ask for the lowest level of permissions you can. You'll almost always only need `whenInUse` (foreground) permission rather than background.\n* On iOS you only get one chance to ask for permission. If the user requests it the first time this method will always resolves to `false`.\n* If you ask for `always` permission then the user gets the chance to accept, but only give you `whenInUse` permission. The Promise will still resolve to `false`, however, if you call `RNLocation.getCurrentPermission` you can check if they actually accepted the lesser permission.\n* You should monitor the permissions and respond to it correctly. The user is able to go to their phone setting and revoke or downgrade permissions at any time.\n\n#### `RNLocation.requestPermission`\nThis method should be called before subscribing to location updates. You need to pass in the type of permission you want for each platform. You can choose not to ignore a platform and it will be ignored. The method returns a promise which resolves to `true` if the permission was granted and `false` if not. For Android you can optionally provide a `rationale` which will be displayed if you ask the user for permission a 2nd time after they have denied permission once.\n\n```javascript\nRNLocation.requestPermission({\n  ios: 'whenInUse', // or 'always'\n  android: {\n    detail: 'coarse', // or 'fine'\n    rationale: {\n      title: \"We need to access your location\",\n      message: \"We use your location to show where you are on the map\",\n      buttonPositive: \"OK\",\n      buttonNegative: \"Cancel\"\n    }\n  }\n});\n```\n\n#### `RNLocation.checkPermission`\nChecks if the currently granted permissions match the given options. You can call this before `requestPermission` to check if you already have the permission level you would like. This is especially useful if you want to display a message to the user about not having the correct permissions before actually requesting them.\n\n```javascript\nRNLocation.checkPermission({\n  ios: 'whenInUse', // or 'always'\n  android: {\n    detail: 'coarse' // or 'fine'\n  }\n});\n```\n\n#### `RNLocation.getCurrentPermission`\nGets the current permission status. Note that the values will be different on Android and iOS as the permission systems are different. It's usually best to use `RNLocation.checkPermission` instead of checking the permission status yourself to avoid re-implementing the logic.\n\n```javascript\nRNLocation.getCurrentPermission()\n  .then(currentPermission =\u003e {\n    ...\n  })\n```\n\n#### `RNLocation.subscribeToPermissionUpdates`\nMonitor the permission status for changes.\n\n```javascript\n// Subscribe\nconst unsubscribe = RNLocation.subscribeToPermissionUpdates(currentPermission =\u003e {\n  ...\n})\n\n// Unsubscribe\nunsubscribe();\n```\n\n### `RNLocation.subscribeToLocationUpdates`\nSubscribe to location changes with the given listener. Ensure you have the correct permission before calling this method. The location provider will respect the settings you have given it. Each event may return an array with more than one location. This is because the OS might batch location updates together and deliver them all at once. Take a look at the `timestamp` to find the latest.\n\n```javascript\n// Subscribe\nconst unsubscribe = RNLocation.subscribeToLocationUpdates(locations =\u003e {\n  ...\n})\n\n// Unsubscribe\nunsubscribe();\n```\n\n### `RNLocation.getLatestLocation`\nGet the latest location. Ensure you have the correct permission before calling this method.\n\nThis will subscribe to location events for you at the unsubscribe when it gets its first valid location. Usually, this method will return very fast with a possibly out of date location, however, in some circumstances it will not return a location. Therefore, this method has a timeout after which the promise will be resovled with `null` value.\n\nThe location provider will respect the settings you have given it, so if you need a location with a certain accuracy, ensure you call `RNLocation.configure` first. If you want *any* location then ensure you call `RNLocation.configure` with no distance filter.\n\n```javascript\nRNLocation.configure({ distanceFilter: null });\nRNLocation.getLatestLocation({ timeout: 60000 })\n  .then(latestLocation =\u003e {\n    // Use the location here\n  })\n```\n\n### `RNLocation.subscribeToSignificantLocationUpdates` (iOS only)\nSubscribe to significant updates to the users location with the given listener. *This method does not take into account the `distanceFilter` which you configured RNLocation with.* In most cases, you should call `RNLocation.configure` with the correct settings and then use `RNLocation.subscribeToLocationUpdates` to subscribe to the location updates. This will allow you to support both Android and iOS with the same code. For more details, take a look at [Apple's documentation](https://developer.apple.com/documentation/corelocation/cllocationmanager/1423531-startmonitoringsignificantlocati?language=objc). \n\n```javascript\n// Subscribe\nconst unsubscribe = RNLocation.subscribeToSignificantLocationUpdates(locations =\u003e {\n  ...\n})\n\n// Unsubscribe\nunsubscribe();\n```\n\n### `RNLocation.subscribeToHeadingUpdates` (iOS only)\nSubscribe to heading changes with the given listener. Ensure you have the correct permission before calling this method. The location provider will respect the settings you have given it.\n\n```javascript\n// Subscribe\nconst unsubscribe = RNLocation.subscribeToHeadingUpdates(heading =\u003e {\n  ...\n})\n\n// Unsubscribe\nunsubscribe();\n```\n\n## License\nThe library is released under the MIT licence. For more information see `LICENSE`.\n","funding_links":[],"categories":["Components","JavaScript"],"sub_categories":["System"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimfpark%2Freact-native-location","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimfpark%2Freact-native-location","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimfpark%2Freact-native-location/lists"}