Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor-community/background-geolocation

Package Overview
Dependencies
Maintainers
31
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/background-geolocation - npm Package Compare versions

Comparing version 0.3.11 to 1.0.0

2

definitions.d.ts

@@ -39,3 +39,3 @@ import {CallbackID} from "@capacitor/core/dist/esm/core-plugin-definitions";

) => void
): CallbackID;
): Promise<CallbackID>;
removeWatcher(options: {

@@ -42,0 +42,0 @@ id: CallbackID

{
"name": "@capacitor-community/background-geolocation",
"version": "0.3.11",
"version": "1.0.0",
"description": "Receive geolocation updates even while app is backgrounded.",

@@ -25,8 +25,8 @@ "repository": {

"devDependencies": {
"@capacitor/android": "^2.4.2",
"@capacitor/core": "^2.4.2",
"@capacitor/ios": "^2.4.2"
"@capacitor/android": "^3.0.0-rc.0",
"@capacitor/core": "^3.0.0-rc.0",
"@capacitor/ios": "^3.0.0-rc.0"
},
"peerDependencies": {
"@capacitor/core": "^2.0.0"
"@capacitor/core": "^3.0.0-rc.0"
},

@@ -33,0 +33,0 @@ "capacitor": {

# Background Geolocation
Capacitor plugin which lets you receive geolocation updates even while the app is backgrounded.
Tested with Capacitor v2. iOS and Android platforms only.
A Capacitor plugin which lets you receive geolocation updates even while the app is backgrounded. Only iOS and Android platforms are supported.

@@ -8,11 +7,12 @@ ## Usage

```javascript
import {Plugins} from "@capacitor/core";
const {BackgroundGeolocation, Modals} = Plugins;
import {registerPlugin} from "@capacitor/core";
const BackgroundGeolocation = registerPlugin("BackgroundGeolocation");
// To start listening for changes in the device's location, add a new watcher.
// You do this by calling 'addWatcher' with an options object and a callback. An
// ID is returned, which can be used to remove the watcher in the future. The
// callback will be called every time a new location is available. Watchers can
// not be paused, only removed. Multiple watchers may exist at the same time.
const watcher_id = BackgroundGeolocation.addWatcher(
// You do this by calling 'addWatcher' with an options object and a callback. A
// Promise is returned, which resolves to the callback ID used to remove the
// watcher in the future. The callback will be called every time a new location
// is available. Watchers can not be paused, only removed. Multiple watchers may
// exist simultaneously.
BackgroundGeolocation.addWatcher(
{

@@ -50,18 +50,13 @@ // If the "backgroundMessage" option is defined, the watcher will

if (error.code === "NOT_AUTHORIZED") {
Modals.confirm({
title: "Location Required",
message: (
"This app needs your location, " +
"but does not have permission.\n\n" +
"Open settings now?"
)
}).then(function ({value}) {
if (value) {
// It can be useful to direct the user to their device's
// settings when location permissions have been denied.
// The plugin provides 'openSettings' to do exactly
// this.
BackgroundGeolocation.openSettings();
}
});
if (window.confirm(
"This app needs your location, " +
"but does not have permission.\n\n" +
"Open settings now?"
)) {
// It can be useful to direct the user to their device's
// settings when location permissions have been denied. The
// plugin provides the 'openSettings' method to do exactly
// this.
BackgroundGeolocation.openSettings();
}
}

@@ -73,8 +68,8 @@ return console.error(error);

}
);
// When a watcher is no longer needed, it should be removed by calling
// 'removeWatcher' with an object containing its ID.
BackgroundGeolocation.removeWatcher({
id: watcher_id
).then(function after_the_watcher_has_been_added(watcher_id) {
// When a watcher is no longer needed, it should be removed by calling
// 'removeWatcher' with an object containing its ID.
BackgroundGeolocation.removeWatcher({
id: watcher_id
});
});

@@ -107,3 +102,3 @@

let last_location;
let id = Plugins.BackgroundGeolocation.addWatcher(
BackgroundGeolocation.addWatcher(
{

@@ -116,8 +111,8 @@ requestPermissions: false,

}
);
setTimeout(function () {
callback(last_location);
Plugins.BackgroundGeolocation.removeWatcher({id});
}, timeout);
).then(function (id) {
setTimeout(function () {
callback(last_location);
Plugins.BackgroundGeolocation.removeWatcher({id});
}, timeout);
});
}

@@ -129,6 +124,8 @@ ```

```typescript
// Capacitor 2.x
import {
BackgroundGeolocationPlugin
} from "@capacitor-community/background-geolocation";
// Capacitor v3
import {BackgroundGeolocationPlugin} from "@capacitor-community/background-geolocation";
const BackgroundGeolocation = registerPlugin<BackgroundGeolocationPlugin>("BackgroundGeolocation");
// Capacitor v2
import {BackgroundGeolocationPlugin} from "@capacitor-community/background-geolocation";
const BackgroundGeolocation = Plugins.BackgroundGeolocation as BackgroundGeolocationPlugin;

@@ -138,2 +135,10 @@ ```

## Installation
Different versions of the plugin support different versions of Capacitor:
| Capacitor | Plugin |
|------------|--------|
| v2 | v0.3 |
| v3 | v1 |
```sh

@@ -163,3 +168,3 @@ npm install @capacitor-community/background-geolocation

### Android
Import the plugin in `MainActivity.java`:
If you are using Capacitor v2, you must import the plugin in `MainActivity.java`. This step is __not__ required for Capacitor v3.

@@ -216,2 +221,7 @@ ```java

leading "@". It defaults to "mipmap/ic_launcher", the app's launch icon.
If a raster image is used to generate the icon (as opposed to a vector
image), it must have a transparent background. To make sure your image
is compatible, select "Notification Icons" as the Icon Type when
creating the image asset in Android Studio.
-->

@@ -224,1 +234,9 @@ <string name="capacitor_background_geolocation_notification_icon">

```
## Changelog
### v1.0.0
- BREAKING: `addWatcher` now returns a Promise which resolves to the callback ID, rather than the callback ID itself.
- BREAKING: The plugin is imported via Capacitor's `registerPlugin` function, rather than from the `Plugins` object.
- Adds support for Capacitor v3
- Drops support for iOS v11

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc