capacitor-background-location
v1.3.33
Published
this plugins ensures to get the location in background when app is suspended
Downloads
7
Maintainers
Readme
capacitor-background-location
this plugins ensures to get the location in background when app is suspended
Install
npm install capacitor-background-location
npx cap sync
API
setConfig(...)
getGpsStatus()
start(...)
stop()
addListener(...)
addListener(...)
removeAllListeners()
- Interfaces
- Enums
setConfig(...)
setConfig(config: IConfig) => Promise<{}>
| Param | Type |
| ------------ | ------------------------------------------- |
| config
| IConfig |
Returns: Promise<{}>
getGpsStatus()
getGpsStatus() => Promise<IGpsStatus>
Returns: Promise<IGpsStatus>
start(...)
start(options: IStartOptions) => Promise<{}>
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options
| IStartOptions |
Returns: Promise<{}>
stop()
stop() => Promise<{}>
Returns: Promise<{}>
addListener(...)
addListener(eventName: EVENTS.Change, callback: (location: ILocation) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
| Param | Type |
| --------------- | ---------------------------------------------------------------------- |
| eventName
| EVENTS.Change |
| callback
| (location: ILocation) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(...)
addListener(eventName: EVENTS.Error, callback: (err?: any) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
| Param | Type |
| --------------- | ----------------------------------------------- |
| eventName
| EVENTS.Error |
| callback
| (err?: any) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
removeAllListeners()
removeAllListeners() => Promise<void>
Interfaces
IConfig
| Prop | Type |
| ----------------- | --------------------------------------- |
| title
| string |
| description
| string |
| url
| string |
| headers
| { [key: string]: string; } |
| body
| { [key: string]: any; } |
IGpsStatus
| Prop | Type |
| ------------ | -------------------- |
| status
| boolean |
IStartOptions
| Prop | Type |
| ---------------------- | ------------------------------------------------------------------------------- |
| interval
| number |
| locationPriority
| LOCATION_PRIORITY_ANDROID |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
ILocation
| Prop | Type |
| --------------- | ------------------- |
| latitude
| number |
| longitude
| number |
| accuracy
| number |
| altitude
| number |
| bearing
| number |
| angle
| number |
| speed
| number |
| time
| string |
Enums
LOCATION_PRIORITY_ANDROID
| Members | Value |
| -------------------------------------- | ---------------- |
| PRIORITY_HIGH_ACCURACY
| 100 |
| PRIORITY_BALANCED_POWER_ACCURACY
| 102 |
| PRIORITY_LOW_POWER
| 104 |
| PRIORITY_NO_POWER
| 105 |
EVENTS
| Members | Value |
| ------------ | --------------------- |
| Change
| "CHANGE" |
| Error
| "ERROR" |
ANDROID
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
And add xmlns:tools="http://schemas.android.com/tools"
to AndroidManifest.xml
<key>NSLocationAlwaysUsageDescription</key>
<string>Description</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Description</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Description</string>
And enable to Location update
from Signing & Capabilities
in xcode