{"id":4503,"url":"https://github.com/mauron85/react-native-background-geolocation","last_synced_at":"2025-12-24T07:54:56.469Z","repository":{"id":8959710,"uuid":"60127046","full_name":"mauron85/react-native-background-geolocation","owner":"mauron85","description":"Background and foreground geolocation plugin for React Native. Tracks user when app is running in background.","archived":false,"fork":false,"pushed_at":"2024-08-20T03:31:58.000Z","size":984,"stargazers_count":1345,"open_issues_count":98,"forks_count":569,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-07-20T13:24:32.470Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mauron85.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-31T22:09:08.000Z","updated_at":"2025-07-15T22:23:08.000Z","dependencies_parsed_at":"2023-01-13T15:05:35.008Z","dependency_job_id":null,"html_url":"https://github.com/mauron85/react-native-background-geolocation","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/mauron85/react-native-background-geolocation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauron85%2Freact-native-background-geolocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauron85%2Freact-native-background-geolocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauron85%2Freact-native-background-geolocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauron85%2Freact-native-background-geolocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mauron85","download_url":"https://codeload.github.com/mauron85/react-native-background-geolocation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauron85%2Freact-native-background-geolocation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268636407,"owners_count":24282085,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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:14.565Z","updated_at":"2025-12-24T07:54:51.446Z","avatar_url":"https://github.com/mauron85.png","language":"Java","funding_links":["https://issuehunt.io/r/mauron85/react-native-background-geolocation/","https://issuehunt.io/r/mauron85/react-native-background-geolocation/issues"],"categories":["Components"],"sub_categories":["Geolocation"],"readme":"# @mauron85/react-native-background-geolocation\n\n[![CircleCI](https://circleci.com/gh/mauron85/react-native-background-geolocation/tree/master.svg?style=shield)](https://circleci.com/gh/mauron85/react-native-background-geolocation/tree/master)\n[![issuehunt-shield-v1](issuehunt-shield-v1.svg)](https://issuehunt.io/r/mauron85/react-native-background-geolocation/)\n\n## We're moving\n\nNpm package is now [@mauron85/react-native-background-geolocation](https://www.npmjs.com/package/@mauron85/react-native-background-geolocation)!\n\n## Submitting issues\n\nAll new issues should follow instructions in [ISSUE_TEMPLATE.md](https://raw.githubusercontent.com/mauron85/react-native-background-geolocation/master/ISSUE_TEMPLATE.md).\nA properly filled issue report will significantly reduce number of follow up questions and decrease issue resolving time.\nMost issues cannot be resolved without debug logs. Please try to isolate debug lines related to your issue.\nInstructions for how to prepare debug logs can be found in section [Debugging](#debugging).\nIf you're reporting an app crash, debug logs might not contain all the necessary information about the cause of the crash.\nIn that case, also provide relevant parts of output of `adb logcat` command.\n\n## Issue Hunt\n\nFund your issues or feature request to drag attraction of developers. Checkout our [issue hunt page](https://issuehunt.io/r/mauron85/react-native-background-geolocation/issues).\n\n# Android background service issues\nThere are repeatedly reported issues with some android devices not working in the background. Check if your device model is on  [dontkillmyapp list](https://dontkillmyapp.com) before you report new issue. For more information check out [dontkillmyapp.com](https://dontkillmyapp.com/problem).\n\nAnother confusing fact about Android services is concept of foreground services. Foreground service in context of Android OS is different thing than background geolocation service of this plugin (they're related thought). **Plugin's background geolocation service** actually **becomes foreground service** when app is in the background. Confusing, right? :D\n\nIf service wants to continue to run in the background, it must \"promote\" itself to `foreground service`. Foreground services must have visible notification, which is the reason, why you can't disable drawer notification.\n\nThe notification can only be disabled, when app is running in the foreground, by setting config option `startForeground: false` (this is the default option), but will always be visible in the background (if service was started).\n\nRecommend you to read https://developer.android.com/about/versions/oreo/background\n\n## Description\nReact Native fork of [cordova-plugin-background-geolocation](https://github.com/mauron85/cordova-plugin-background-geolocation)\nwith battery-saving \"circular region monitoring\" and \"stop detection\".\n\nThis plugin can be used for geolocation when the app is running in the foreground or background.\n\nYou can choose from following location providers:\n* **DISTANCE_FILTER_PROVIDER**\n* **ACTIVITY_PROVIDER**\n* **RAW_PROVIDER**\n\nSee [Which provider should I use?](/PROVIDERS.md) for more information about providers.\n\n## Dependencies\n\nVersions of libraries and sdk versions used to compile this plugin can be overriden in\n`android/build.gradle` with ext declaration.\n\nWhen ext is not provided then following defaults will be used:\n\n```\next {\n  compileSdkVersion = 28\n  buildToolsVersion = \"28.0.3\"\n  targetSdkVersion = 28\n  minSdkVersion = 16\n  supportLibVersion = \"28.0.0\"\n  googlePlayServicesVersion = \"11+\"\n}\n```\n\n## Compatibility\n\nDue to the rapid changes being made in the React Native ecosystem, this module will support\nonly the latest version of React Native. Older versions will only be supported if they're\ncompatible with this module.\n\n| Module           | React Native      |\n|------------------|-------------------|\n| 0.1.0 - 0.2.0    | 0.33              |\n| \u003e=0.3.0          | \u003e=0.47            |\n| \u003e=0.6.0          | \u003e=0.60            |\n\nIf you are using an older version of React Native with this module some features may be buggy.\n\nIf you are using `react-native-maps` or another lib that requires `Google Play Services` such as `Exponent.js`, then in addition to the instalation steps described here, you must set `Google Play Services` library version to match the version used by those libraries. (in this case `9.8.0`)\n\nAdd following to `android/build.gradle`\n```\next {\n  googlePlayServicesVersion = \"9.8.0\"\n}\n```\n\n## Example Apps\n\nThe repository [react-native-background-geolocation-example](https://github.com/mauron85/react-native-background-geolocation-example) hosts an example app for both iOS and Android platform.\n\n## Quick example\n\n```javascript\nimport React, { Component } from 'react';\nimport { Alert } from 'react-native';\nimport BackgroundGeolocation from '@mauron85/react-native-background-geolocation';\n\nclass BgTracking extends Component {\n  componentDidMount() {\n    BackgroundGeolocation.configure({\n      desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY,\n      stationaryRadius: 50,\n      distanceFilter: 50,\n      notificationTitle: 'Background tracking',\n      notificationText: 'enabled',\n      debug: true,\n      startOnBoot: false,\n      stopOnTerminate: true,\n      locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER,\n      interval: 10000,\n      fastestInterval: 5000,\n      activitiesInterval: 10000,\n      stopOnStillActivity: false,\n      url: 'http://192.168.81.15:3000/location',\n      httpHeaders: {\n        'X-FOO': 'bar'\n      },\n      // customize post properties\n      postTemplate: {\n        lat: '@latitude',\n        lon: '@longitude',\n        foo: 'bar' // you can also add your own properties\n      }\n    });\n\n    BackgroundGeolocation.on('location', (location) =\u003e {\n      // handle your locations here\n      // to perform long running operation on iOS\n      // you need to create background task\n      BackgroundGeolocation.startTask(taskKey =\u003e {\n        // execute long running task\n        // eg. ajax post location\n        // IMPORTANT: task has to be ended by endTask\n        BackgroundGeolocation.endTask(taskKey);\n      });\n    });\n\n    BackgroundGeolocation.on('stationary', (stationaryLocation) =\u003e {\n      // handle stationary locations here\n      Actions.sendLocation(stationaryLocation);\n    });\n\n    BackgroundGeolocation.on('error', (error) =\u003e {\n      console.log('[ERROR] BackgroundGeolocation error:', error);\n    });\n\n    BackgroundGeolocation.on('start', () =\u003e {\n      console.log('[INFO] BackgroundGeolocation service has been started');\n    });\n\n    BackgroundGeolocation.on('stop', () =\u003e {\n      console.log('[INFO] BackgroundGeolocation service has been stopped');\n    });\n\n    BackgroundGeolocation.on('authorization', (status) =\u003e {\n      console.log('[INFO] BackgroundGeolocation authorization status: ' + status);\n      if (status !== BackgroundGeolocation.AUTHORIZED) {\n        // we need to set delay or otherwise alert may not be shown\n        setTimeout(() =\u003e\n          Alert.alert('App requires location tracking permission', 'Would you like to open app settings?', [\n            { text: 'Yes', onPress: () =\u003e BackgroundGeolocation.showAppSettings() },\n            { text: 'No', onPress: () =\u003e console.log('No Pressed'), style: 'cancel' }\n          ]), 1000);\n      }\n    });\n\n    BackgroundGeolocation.on('background', () =\u003e {\n      console.log('[INFO] App is in background');\n    });\n\n    BackgroundGeolocation.on('foreground', () =\u003e {\n      console.log('[INFO] App is in foreground');\n    });\n\n    BackgroundGeolocation.on('abort_requested', () =\u003e {\n      console.log('[INFO] Server responded with 285 Updates Not Required');\n\n      // Here we can decide whether we want stop the updates or not.\n      // If you've configured the server to return 285, then it means the server does not require further update.\n      // So the normal thing to do here would be to `BackgroundGeolocation.stop()`.\n      // But you might be counting on it to receive location updates in the UI, so you could just reconfigure and set `url` to null.\n    });\n\n    BackgroundGeolocation.on('http_authorization', () =\u003e {\n      console.log('[INFO] App needs to authorize the http requests');\n    });\n\n    BackgroundGeolocation.checkStatus(status =\u003e {\n      console.log('[INFO] BackgroundGeolocation service is running', status.isRunning);\n      console.log('[INFO] BackgroundGeolocation services enabled', status.locationServicesEnabled);\n      console.log('[INFO] BackgroundGeolocation auth status: ' + status.authorization);\n\n      // you don't need to check status before start (this is just the example)\n      if (!status.isRunning) {\n        BackgroundGeolocation.start(); //triggers start on start event\n      }\n    });\n\n    // you can also just start without checking for status\n    // BackgroundGeolocation.start();\n  }\n\n  componentWillUnmount() {\n    // unregister all event listeners\n    BackgroundGeolocation.removeAllListeners();\n  }\n}\n\nexport default BgTracking;\n```\n\n## Instalation\n\n### Installation\n\nAdd the package to your project\n\n```\nyarn add @mauron85/react-native-background-geolocation\n```\n\n### Automatic setup\n\nSince version 0.60 React Native does linking of modules [automatically](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md). However it does it only for single module.\nAs plugin depends on additional 'common' module, it is required to link it with:\n\n```\nnode ./node_modules/@mauron85/react-native-background-geolocation/scripts/postlink.js\n```\n\n### Manual setup\n\n#### Android setup\n\nIn `android/settings.gradle`\n\n```gradle\n...\ninclude ':@mauron85_react-native-background-geolocation-common'\nproject(':@mauron85_react-native-background-geolocation-common').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/common')\ninclude ':@mauron85_react-native-background-geolocation'\nproject(':@mauron85_react-native-background-geolocation').projectDir = new File(rootProject.projectDir, '../node_modules/@mauron85/react-native-background-geolocation/android/lib')\n...\n```\n\nIn `android/app/build.gradle`\n\n```gradle\ndependencies {\n    ...\n    compile project(':@mauron85_react-native-background-geolocation')\n    ...\n}\n```\n\nRegister the module (in `MainApplication.java`)\n\n```java\nimport com.marianhello.bgloc.react.BackgroundGeolocationPackage;  // \u003c--- Import Package\n\npublic class MainApplication extends Application implements ReactApplication {\n  ...\n  /**\n   * A list of packages used by the app. If the app uses additional views\n   * or modules besides the default ones, add more packages here.\n   */\n  @Override\n  protected List\u003cReactPackage\u003e getPackages() {\n      return Arrays.\u003cReactPackage\u003easList(\n          new MainReactPackage(),\n          new BackgroundGeolocationPackage() // \u003c---- Add the Package\n      );\n  }\n  ...\n}\n```\n\n#### iOS setup\n\n1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\n2. Add `./node_modules/@mauron85/react-native-background-geolocation/ios/RCTBackgroundGeolocation.xcodeproj`\n3. In the XCode project navigator, select your project, select the `Build Phases` tab and in the `Link Binary With Libraries` section add **libRCTBackgroundGeolocation.a**\n4. Add `UIBackgroundModes` **location** to `Info.plist`\n5. Add `NSMotionUsageDescription` **App requires motion tracking** to `Info.plist` (required by ACTIVITY_PROVIDER)\n\nFor iOS before version 11:\n\n6. Add `NSLocationAlwaysUsageDescription` **App requires background tracking** to `Info.plist`\n\nFor iOS 11:\n\n6. Add `NSLocationWhenInUseUsageDescription` **App requires background tracking** to `Info.plist`\n7. Add `NSLocationAlwaysAndWhenInUseUsageDescription` **App requires background tracking** to `Info.plist`\n\n## API\n\n### configure(options, success, fail)\n\n| Parameter | Type          | Platform | Description                                                                     |\n|-----------|---------------|----------|---------------------------------------------------------------------------------|\n| `options` | `JSON Object` | all      | Configure options                                                               |\n\nConfigure options:\n\n| Parameter                 | Type              | Platform     | Description                                                                                                                                                                                                                                                                                                                                        | Provider*   | Default                    | \n|---------------------------|-------------------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|----------------------------|\n| `locationProvider`        | `Number`          | all          | Set location provider **@see** [PROVIDERS](/PROVIDERS.md)                                                                                                                                                                                                                                                                                          | N/A         | DISTANCE\\_FILTER\\_PROVIDER | \n| `desiredAccuracy`         | `Number`          | all          | Desired accuracy in meters. Possible values [HIGH_ACCURACY, MEDIUM_ACCURACY, LOW_ACCURACY, PASSIVE_ACCURACY]. Accuracy has direct effect on power drain. Lower accuracy = lower power drain.                                                                                                                                                       | all         | MEDIUM\\_ACCURACY           | \n| `stationaryRadius`        | `Number`          | all          | Stationary radius in meters. When stopped, the minimum distance the device must move beyond the stationary location for aggressive background-tracking to engage.                                                                                                                                                                                  | DIS         | 50                         | \n| `debug`                   | `Boolean`         | all          | When enabled, the plugin will emit sounds for life-cycle events of background-geolocation! See debugging sounds table.                                                                                                                                                                                                                             | all         | false                      | \n| `distanceFilter`          | `Number`          | all          | The minimum distance (measured in meters) a device must move horizontally before an update event is generated. **@see** [Apple docs](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/distanceFilter).        | DIS,RAW     | 500                        | \n| `stopOnTerminate`         | `Boolean`         | all          | Enable this in order to force a stop() when the application terminated (e.g. on iOS, double-tap home button, swipe away the app).                                                                                                                                                                                                                  | all         | true                       | \n| `startOnBoot`             | `Boolean`         | Android      | Start background service on device boot.                                                                                                                                                                                                                                                                                                           | all         | false                      | \n| `interval`                | `Number`          | Android      | The minimum time interval between location updates in milliseconds. **@see** [Android docs](http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(long,%20float,%20android.location.Criteria,%20android.app.PendingIntent)) for more information.                                                    | all         | 60000                      | \n| `fastestInterval`         | `Number`          | Android      | Fastest rate in milliseconds at which your app can handle location updates. **@see** [Android  docs](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#getFastestInterval()).                                                                                                                   | ACT         | 120000                     | \n| `activitiesInterval`      | `Number`          | Android      | Rate in milliseconds at which activity recognition occurs. Larger values will result in fewer activity detections while improving battery life.                                                                                                                                                                                                    | ACT         | 10000                      | \n| `stopOnStillActivity`     | `Boolean`         | Android      | @deprecated stop location updates, when the STILL activity is detected                                                                                                                                                                                                                                                                             | ACT         | true                       | \n| `notificationsEnabled`    | `Boolean`         | Android      | Enable/disable local notifications when tracking and syncing locations                                                                                                                                                                                                                                                                             | all         | true                       |\n| `startForeground`         | `Boolean`         | Android      | Allow location sync service to run in foreground state. Foreground state also requires a notification to be presented to the user.                                                                                                                                                                                                                 | all         | false                      |\n| `notificationTitle`       | `String` optional | Android      | Custom notification title in the drawer. (goes with `startForeground`)                                                                                                                                                                                                                                                                             | all         | \"Background tracking\"      | \n| `notificationText`        | `String` optional | Android      | Custom notification text in the drawer. (goes with `startForeground`)                                                                                                                                                                                                                                                                              | all         | \"ENABLED\"                  | \n| `notificationIconColor`   | `String` optional | Android      | The accent color to use for notification. Eg. **#4CAF50**. (goes with `startForeground`)                                                                                                                                                                                                                                                           | all         |                            | \n| `notificationIconLarge`   | `String` optional | Android      | The filename of a custom notification icon. **@see** Android quirks. (goes with `startForeground`)                                                                                                                                                                                                                                                 | all         |                            | \n| `notificationIconSmall`   | `String` optional | Android      | The filename of a custom notification icon. **@see** Android quirks. (goes with `startForeground`)                                                                                                                                                                                                                                                 | all         |                            | \n| `activityType`            | `String`          | iOS          | [AutomotiveNavigation, OtherNavigation, Fitness, Other] Presumably, this affects iOS GPS algorithm. **@see** [Apple docs](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/activityType) for more information | all         | \"OtherNavigation\"          | \n| `pauseLocationUpdates`    | `Boolean`         | iOS          | Pauses location updates when app is paused. **@see* [Apple docs](https://developer.apple.com/documentation/corelocation/cllocationmanager/1620553-pauseslocationupdatesautomatical?language=objc)                                                                                                                                                  | all         | false                      | \n| `saveBatteryOnBackground` | `Boolean`         | iOS          | Switch to less accurate significant changes and region monitory when in background                                                                                                                                                                                                                                                                 | all         | false                      | \n| `url`                     | `String`          | all          | Server url where to send HTTP POST with recorded locations **@see** [HTTP locations posting](#http-locations-posting)                                                                                                                                                                                                                              | all         |                            | \n| `syncUrl`                 | `String`          | all          | Server url where to send fail to post locations **@see** [HTTP locations posting](#http-locations-posting)                                                                                                                                                                                                                                         | all         |                            | \n| `syncThreshold`           | `Number`          | all          | Specifies how many previously failed locations will be sent to server at once                                                                                                                                                                                                                                                                      | all         | 100                        | \n| `httpHeaders`             | `Object`          | all          | Optional HTTP headers sent along in HTTP request                                                                                                                                                                                                                                                                                                   | all         |                            | \n| `maxLocations`            | `Number`          | all          | Limit maximum number of locations stored into db                                                                                                                                                                                                                                                                                                   | all         | 10000                      | \n| `postTemplate`            | `Object\\|Array`   | all          | Customization post template **@see** [Custom post template](#custom-post-template)                                                                                                                                                                                                                                                                 | all         |                            | \n\n\\*\nDIS = DISTANCE\\_FILTER\\_PROVIDER\nACT = ACTIVITY\\_PROVIDER\nRAW = RAW\\_PROVIDER\n\n\nPartial reconfiguration is possible by later providing a subset of the configuration options:\n\n```\nBackgroundGeolocation.configure({\n  debug: true\n});\n```\n\nIn this case new configuration options will be merged with stored configuration options and changes will be applied immediately.\n\n**Important:** Because configuration options are applied partially, it's not possible to reset option to default value just by omitting it's key name and calling `configure` method. To reset configuration option to the default value, it's key must be set to `null`!\n\n```\n// Example: reset postTemplate to default\nBackgroundGeolocation.configure({\n  postTemplate: null\n});\n```\n\n### getConfig(success, fail)\nPlatform: iOS, Android\n\nGet current configuration. Method will return all configuration options and their values in success callback.\nBecause `configure` method can be called with subset of the configuration options only,\n`getConfig` method can be used to check the actual applied configuration.\n\n```\nBackgroundGeolocation.getConfig(function(config) {\n  console.log(config);\n});\n```\n\n### start()\nPlatform: iOS, Android\n\nStart background geolocation.\n\n### stop()\nPlatform: iOS, Android\n\nStop background geolocation.\n\n### getCurrentLocation(success, fail, options)\nPlatform: iOS, Android\n\nOne time location check to get current location of the device.\n\n| Option parameter           | Type      | Description                                                                            |\n|----------------------------|-----------|----------------------------------------------------------------------------------------|\n| `timeout`                  | `Number`  | Maximum time in milliseconds device will wait for location                             |\n| `maximumAge`               | `Number`  | Maximum age in milliseconds of a possible cached location that is acceptable to return |\n| `enableHighAccuracy`       | `Boolean` | if true and if the device is able to provide a more accurate position, it will do so   |\n\n| Success callback parameter | Type      | Description                                                    |\n|----------------------------|-----------|----------------------------------------------------------------|\n| `location`                 | `Object`  | location object (@see [Location event](#location-event))       |\n\n| Error callback parameter   | Type      | Description                                                    |\n|----------------------------|-----------|----------------------------------------------------------------|\n| `code`                     | `Number`  | Reason of an error occurring when using the geolocating device |\n| `message`                  | `String`  | Message describing the details of the error                    |\n\nError codes:\n\n| Value | Associated constant  | Description                                                              |\n|-------|----------------------|--------------------------------------------------------------------------|\n| 1     | PERMISSION_DENIED    | Request failed due missing permissions                                   |\n| 2     | LOCATION_UNAVAILABLE | Internal source of location returned an internal error                   |\n| 3     | TIMEOUT              | Timeout defined by `option.timeout was exceeded                          |\n\n### checkStatus(success, fail)\n\nCheck status of the service\n\n| Success callback parameter | Type      | Description                                          |\n|----------------------------|-----------|------------------------------------------------------|\n| `isRunning`                | `Boolean` | true/false (true if service is running)              |\n| `locationServicesEnabled`  | `Boolean` | true/false (true if location services are enabled)   |\n| `authorization`            | `Number`  | authorization status                                 |\n\nAuthorization statuses:\n\n* NOT_AUTHORIZED\n* AUTHORIZED - authorization to run in background and foreground\n* AUTHORIZED_FOREGROUND iOS only authorization to run in foreground only\n\nNote: In the Android concept of authorization, these represent application permissions.\n\n### showAppSettings()\nPlatform: Android \u003e= 6, iOS \u003e= 8.0\n\nShow app settings to allow change of app location permissions.\n\n### showLocationSettings()\nPlatform: Android\n\nShow system settings to allow configuration of current location sources.\n\n### getLocations(success, fail)\nPlatform: iOS, Android\n\nMethod will return all stored locations.\nThis method is useful for initial rendering of user location on a map just after application launch.\n\n| Success callback parameter | Type    | Description                    |\n|----------------------------|---------|--------------------------------|\n| `locations`                | `Array` | collection of stored locations |\n\n```javascript\nBackgroundGeolocation.getLocations(\n  function (locations) {\n    console.log(locations);\n  }\n);\n```\n\n### getValidLocations(success, fail)\nPlatform: iOS, Android\n\nMethod will return locations which have not yet been posted to server.\n\n| Success callback parameter | Type    | Description                    |\n|----------------------------|---------|--------------------------------|\n| `locations`                | `Array` | collection of stored locations |\n\n### deleteLocation(locationId, success, fail)\nPlatform: iOS, Android\n\nDelete location with locationId.\n\n### deleteAllLocations(success, fail)\nNote: You don't need to delete all locations. The plugin manages the number of stored locations automatically and the total count never exceeds the number as defined by `option.maxLocations`.\n\nPlatform: iOS, Android\n\nDelete all stored locations.\n\nNote: Locations are not actually deleted from database to avoid gaps in locationId numbering.\nInstead locations are marked as deleted. Locations marked as deleted will not appear in output of `BackgroundGeolocation.getValidLocations`.\n\n### switchMode(modeId, success, fail)\nPlatform: iOS\n\nNormally the plugin will handle switching between **BACKGROUND** and **FOREGROUND** mode itself.\nCalling switchMode you can override plugin behavior and force it to switch into other mode.\n\nIn **FOREGROUND** mode the plugin uses iOS local manager to receive locations and behavior is affected\nby `option.desiredAccuracy` and `option.distanceFilter`.\n\nIn **BACKGROUND** mode plugin uses significant changes and region monitoring to receive locations\nand uses `option.stationaryRadius` only.\n\n```\n// switch to FOREGROUND mode\nBackgroundGeolocation.switchMode(BackgroundGeolocation.FOREGROUND_MODE);\n\n// switch to BACKGROUND mode\nBackgroundGeolocation.switchMode(BackgroundGeolocation.BACKGROUND_MODE);\n```\n### forceSync()\nPlatform: Android, iOS\n\nForce sync of pending locations. Option `syncThreshold` will be ignored and\nall pending locations will be immediately posted to `syncUrl` in single batch.\n\n### getLogEntries(limit, fromId, minLevel, success, fail)\nPlatform: Android, iOS\n\nReturn all logged events. Useful for plugin debugging.\n\n| Parameter  | Type          | Description                                                                                       |\n|------------|---------------|---------------------------------------------------------------------------------------------------|\n| `limit`    | `Number`      | limits number of returned entries                                                                 |\n| `fromId`   | `Number`      | return entries after fromId. Useful if you plan to implement infinite log scrolling*              |\n| `minLevel` | `String`      | return log entries above level. Available levels: [\"TRACE\", \"DEBUG\", \"INFO\", \"WARN\", \"ERROR]      |\n| `success`  | `Function`    | callback function which will be called with log entries                                           |\n\n*[Example of infinite log scrolling](https://github.com/mauron85/react-native-background-geolocation-example/blob/master/src/scenes/Logs.js)\n\nFormat of log entry:\n\n| Parameter   | Type          | Description                                                                                       |\n|-------------|---------------|---------------------------------------------------------------------------------------------------|\n| `id`        | `Number`      | id of log entry as stored in db                                                                   |\n| `timestamp` | `Number`      | timestamp in milliseconds since beginning of UNIX epoch                                           |\n| `level`     | `String`      | log level                                                                                         |\n| `message`   | `String`      | log message                                                                                       |\n| `stackTrace`| `String`      | recorded stacktrace (Android only, on iOS part of message)                                        |\n\n### removeAllListeners(event)\n\nUnregister all event listeners for given event. If parameter `event` is not provided then all event listeners will be removed.\n\n## Events\n\n| Name                | Callback param         | Platform     | Provider*   | Description                                      |\n|---------------------|------------------------|--------------|-------------|--------------------------------------------------|\n| `location`          | `Location`             | all          | all         | on location update                               |\n| `stationary`        | `Location`             | all          | DIS,ACT     | on device entered stationary mode                |\n| `activity`          | `Activity`             | Android      | ACT         | on activity detection                            |\n| `error`             | `{ code, message }`    | all          | all         | on plugin error                                  |\n| `authorization`     | `status`               | all          | all         | on user toggle location service                  |\n| `start`             |                        | all          | all         | geolocation has been started                     |\n| `stop`              |                        | all          | all         | geolocation has been stopped                     |\n| `foreground`        |                        | Android      | all         | app entered foreground state (visible)           |\n| `background`        |                        | Android      | all         | app entered background state                     |\n| `abort_requested`   |                        | all          | all         | server responded with \"285 Updates Not Required\" |\n| `http_authorization`|                        | all          | all         | server responded with \"401 Unauthorized\"         |\n\n### Location event\n| Location parameter     | Type      | Description                                                            |\n|------------------------|-----------|------------------------------------------------------------------------|\n| `id`                   | `Number`  | ID of location as stored in DB (or null)                               |\n| `provider`             | `String`  | gps, network, passive or fused                                         |\n| `locationProvider`     | `Number`  | location provider                                                      |\n| `time`                 | `Number`  | UTC time of this fix, in milliseconds since January 1, 1970.           |\n| `latitude`             | `Number`  | Latitude, in degrees.                                                  |\n| `longitude`            | `Number`  | Longitude, in degrees.                                                 |\n| `accuracy`             | `Number`  | Estimated accuracy of this location, in meters.                        |\n| `speed`                | `Number`  | Speed if it is available, in meters/second over ground.                |\n| `altitude`             | `Number`  | Altitude if available, in meters above the WGS 84 reference ellipsoid. |\n| `bearing`              | `Number`  | Bearing, in degrees.                                                   |\n| `isFromMockProvider`   | `Boolean` | (android only) True if location was recorded by mock provider          |\n| `mockLocationsEnabled` | `Boolean` | (android only) True if device has mock locations enabled               |\n\nLocations parameters `isFromMockProvider` and `mockLocationsEnabled` are not posted to `url` or `syncUrl` by default.\nBoth can be requested via option `postTemplate`.\n\nNote: Do not use location `id` as unique key in your database as ids will be reused when `option.maxLocations` is reached.\n\nNote: Android currently returns `time` as type of String (instead of Number) [@see issue #9685](https://github.com/facebook/react-native/issues/9685)\n\n### Activity event\n| Activity parameter | Type      | Description                                                            |\n|--------------------|-----------|------------------------------------------------------------------------|\n| `confidence`       | `Number`  | Percentage indicating the likelihood user is performing this activity. |\n| `type`             | `String`  | \"IN_VEHICLE\", \"ON_BICYCLE\", \"ON_FOOT\", \"RUNNING\", \"STILL\",             |\n|                    |           | \"TILTING\", \"UNKNOWN\", \"WALKING\"                                        |\n\nEvent listeners can registered with:\n\n```\nconst eventSubscription = BackgroundGeolocation.on('event', callbackFn);\n```\n\nAnd unregistered:\n\n```\neventSubscription.remove();\n```\n\nNote: Components should unregister all event listeners in `componentWillUnmount` method,\nindividually, or with `removeAllListeners`\n\n## HTTP locations posting\n\nAll locations updates are recorded in the local db at all times. When the App is in foreground or background, in addition to storing location in local db,\nthe location callback function is triggered. The number of locations stored in db is limited by `option.maxLocations` and never exceeds this number.\nInstead, old locations are replaced by new ones.\n\nWhen `option.url` is defined, each location is also immediately posted to url defined by `option.url`.\nIf the post is successful, the location is marked as deleted in local db.\n\nWhen `option.syncUrl` is defined, all locations that fail to post will be coalesced and sent in some time later in a single batch.\nBatch sync takes place only when the number of failed-to-post locations reaches `option.syncTreshold`.\nLocations are sent only in single batch when the number of locations reaches `option.syncTreshold`. (No individual locations will be sent)\n\nThe request body of posted locations is always an array, even when only one location is sent.\n\nWarning: `option.maxLocations` has to be larger than `option.syncThreshold`. It's recommended to be 2x larger. In any other case the location syncing might not work properly.\n\n## Custom post template\n\nWith `option.postTemplate` it is possible to specify which location properties should be posted to `option.url` or `option.syncUrl`. This can be useful to reduce the\nnumber of bytes sent \"over the \"wire\".\n\nAll wanted location properties have to be prefixed with `@`. For all available properties check [Location event](#location-event).\n\nTwo forms are supported:\n\n**jsonObject**\n\n```\nBackgroundGeolocation.configure({\n  postTemplate: {\n    lat: '@latitude',\n    lon: '@longitude',\n    foo: 'bar' // you can also add your own properties\n  }\n});\n```\n\n**jsonArray**\n```\nBackgroundGeolocation.configure({\n  postTemplate: ['@latitude', '@longitude', 'foo', 'bar']\n});\n```\n\nNote: Keep in mind that all locations (even a single one) will be sent as an array of object(s), when postTemplate is `jsonObject` and array of array(s) for `jsonArray`!\n\n### Android Headless Task (Experimental)\n\nA special task that gets executed when the app is terminated, but the plugin was configured to continue running in the background (option `stopOnTerminate: false`). In this scenario the [Activity](https://developer.android.com/reference/android/app/Activity.html)\nwas killed by the system and all registered event listeners will not be triggered until the app is relaunched.\n\n**Note:** Prefer configuration options `url` and `syncUrl` over headless task. Use it sparingly!\n\n#### Task event\n| Parameter          | Type      | Description                                                            |\n|--------------------|-----------|------------------------------------------------------------------------|\n| `event.name`       | `String`  | Name of the event [ \"location\", \"stationary\", \"activity\" ]             |\n| `event.params`     | `Object`  | Event parameters. @see [Events](#events)                               |\n\nKeep in mind that the callback function lives in an isolated scope. Variables from a higher scope cannot be referenced!\n\nFollowing example requires [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) enabled backend server.\n\n**Warning:** callback function must by `async`!\n\n```\nBackgroundGeolocation.headlessTask(async (event) =\u003e {\n    if (event.name === 'location' ||\n      event.name === 'stationary') {\n        var xhr = new XMLHttpRequest();\n        xhr.open('POST', 'http://192.168.81.14:3000/headless');\n        xhr.setRequestHeader('Content-Type', 'application/json');\n        xhr.send(JSON.stringify(event.params));\n    }\n});\n```\n\n**Important:**\n\nAfter application is launched again (main activity becomes visible), it is important to call `start` method to rebind all event listeners.\n\n```\nBackgroundGeolocation.checkStatus(({ isRunning }) =\u003e {\n  if (isRunning) {\n    BackgroundGeolocation.start(); // service was running -\u003e rebind all listeners\n  }\n});\n```\n\n\n### Transforming/filtering locations in native code\n\nIn some cases you might want to modify a location before posting, reject a location, or any other logic around incoming locations - in native code. There's an option of doing so with a headless task, but you may want to preserve battery, or do more complex actions that are not available in React.\n\nIn those cases you could register a location transform.\n\nAndroid example:\n\nWhen the `Application` is initialized (which also happens before services gets started in the background), write some code like this:\n\n```\nBackgroundGeolocationFacade.setLocationTransform(new LocationTransform() {\n    @Nullable\n    @Override\n    public BackgroundLocation transformLocationBeforeCommit(@NonNull Context context, @NonNull BackgroundLocation location) {\n    // `context` is available too if there's a need to use a value from preferences etc.\n\n    // Modify the location\n    location.setLatitude(location.getLatitude() + 0.018);\n\n    // Return modified location\n    return location;\n\n    // You could return null to reject the location,\n    // or if you did something else with the location and the library should not post or save it.\n    }\n});\n```\n\niOS example:\n\n\nIn `didFinishLaunchingWithOptions` delegate method, write some code like this:\n\n```\nBackgroundGeolocationFacade.locationTransform = ^(MAURLocation * location) {\n  // Modify the location\n  location.latitude = @(location.latitude.doubleValue + 0.018);\n  \n  // Return modified location\n  return location;\n  \n  // You could return null to reject the location,\n  // or if you did something else with the location and the library should not post or save it.\n};\n```\n\n### Advanced plugin configuration\n\n#### Change Account Service Name (Android)\n\nAdd string resource \"account_name\" into \"android/app/src/main/res/values/strings.xml\"\n\n```\n\u003cstring name=\"account_name\"\u003eSync Locations\u003c/string\u003e\n\n```\n\n### Example of backend server\n\n[Background-geolocation-server](https://github.com/mauron85/background-geolocation-server) is a backend server written in nodejs with CORS - Cross-Origin Resource Sharing support.\nThere are instructions how to run it and simulate locations on Android, iOS Simulator and Genymotion.\n\n## Debugging\n\n## Submit crash log\n\nTODO\n\n## Debugging sounds\n| Event                               | *ios*                             | *android*               |\n|-------------------------------------|-----------------------------------|-------------------------|\n| Exit stationary region              | Calendar event notification sound | dialtone beep-beep-beep |\n| Geolocation recorded                | SMS sent sound                    | tt short beep           |\n| Aggressive geolocation engaged      | SIRI listening sound              |                         |\n| Passive geolocation engaged         | SIRI stop listening sound         |                         |\n| Acquiring stationary location sound | \"tick,tick,tick\" sound            |                         |\n| Stationary location acquired sound  | \"bloom\" sound                     | long tt beep            |\n\n**NOTE:** For iOS  in addition, you must manually enable the *Audio and Airplay* background mode in *Background Capabilities* to hear these debugging sounds.\n\n\n## Geofencing\nTry using [react-native-boundary](https://github.com/eddieowens/react-native-boundary). Let's keep this plugin lightweight as much as possible.\n\n## Changelog\n\nSee [CHANGES.md](/CHANGES.md)\n\nSee [变更（非官方中文版）](/CHANGES_zh-Hans.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauron85%2Freact-native-background-geolocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauron85%2Freact-native-background-geolocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauron85%2Freact-native-background-geolocation/lists"}