🆕 🛑 Capacitor version now available! See capacitor-background-geolocation
🛑 🆕
npm install cordova-background-geolocation-lt
npx cap sync
ℹ️ Append optional #version
tag (eg: #3.6.3
) to url above (See Releases)
With YourApp.xcworkspace
open in XCode, add the following Background Modes Capabilities:
- Location updates
- Background fetch
- Audio (optional for debug-mode sound FX)
Edit Info.plist
. Add the following items (Set Value as desired):
Key | Type | Value |
---|---|---|
Privacy - Location Always and When in Use Usage Description | String |
CHANGEME: Location required in background |
Privacy - Location When in Use Usage Description | String |
CHANGEME: Location required when app is in use |
Privacy - Motion Usage Description | String |
CHANGEME: Motion permission helps detect when device in in-motion |
The BackgroundGeolocation SDK makes use internally on cordova-plugin-background-fetch
. Regardless of whether you instend to implement the BackgroundFetch Javascript API in your app, you must perform the Background Fetch iOS Setup at cordova-plugin-background-fetch
.
Add the following code to your build.gradle (Module: app)
:
apply plugin: 'com.android.application'
+def background_geolocation = "../../node_modules/cordova-background-geolocation-lt/src/android"
+apply from: "$background_geolocation/app.gradle"
android {
.
.
.
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardFiles "$background_geolocation/proguard-rules.pro"
}
}
}
If you've not purchased a license, ignore this step — the plugin is fully functional in DEBUG builds so you can try before you buy.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.your.app">
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<!-- background-geolocation licence -->
+ <meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_LICENCE_KEY_HERE" />
.
.
.
</application>
</manifest>