Our Background Location is soon getting an update, which will enable you to track users’ locations accurately even when the phone is on standby.
AI Prompt
Add native background location tracking functionality to continuously monitor user location including latitude, longitude, accuracy, and other positioning data using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: Please follow the installation instructions for the “despia-native” npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
npm install despia-nativeThen import it: import despia from 'despia-native'- Enable background location tracking using
despia("backgroundlocationon://") - Set up location monitoring using the native
navigator.geolocation.watchPosition()API with high accuracy enabled - When finished, disable background location using
despia("backgroundlocationoff://")and clear the watch usingnavigator.geolocation.clearWatch(watchId)
This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
Important: Before implementing, you must go into the Despia editor, navigate to “Addons”, and enable “Background Location”. This will add the necessary native modules into your app to have real native background tracking and background processing capabilities.
despia("backgroundlocationon://") call triggers native methods that accelerate the geolocation API for enhanced performance. First enable background location tracking, then use the native geolocation API to continuously monitor position, and finally disable tracking when complete.
Installation
Install the Despia package from NPM:Usage
1. Import the SDK
2. Enable Background Location and Monitor Position
Start background location tracking and set up continuous monitoring:Resources
- NPM Package
- View full NPM documentation for additional configuration options