New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

background-location-update

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

background-location-update

Gives the user location update in background

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

background-location-update

A Capacitor plugin which lets you receive location updates even while the app is backgrounded.

Install

npm install background-location-update
npx cap sync

Usage

import { BackgroundLocation, Location } from 'background-location-update';

iOS

Add the following keys to Info.plist.:

<dict>
  ...
  <key>NSLocationWhenInUseUsageDescription</key>
  <string>We need to track your location</string>
  <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
  <string>We need to track your location while your device is locked.</string>
  <key>UIBackgroundModes</key>
  <array>
    <string>location</string>
  </array>
  ...
</dict>

Android

Configure AndroidManifest.xml:

<manifest>
    <application>
        <service
            android:name="com.viewtrak.plugins.backgroundlocation.BackgroundLoctionService"
            android:enabled="true"
            android:exported="true"
            android:foregroundServiceType="location" />
    </application>

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-feature android:name="android.hardware.location.gps" />
</manifest>

Configration specific to Android can be made in strings.xml:

<resources>
    <!--
        The channel name for the background notification. This will be visible
        when the user presses & holds the notification. It defaults to
        "Background Tracking".
    -->
    <string name="capacitor_background_location_notification_channel_name">
        Background Tracking
    </string>

    <!--
        The icon to use for the background notification. Note the absence of a
        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.
    -->
    <string name="capacitor_background_location_notification_icon">
        drawable/ic_tracking
    </string>
</resources>

API

  • addWatcher(...)
  • removeWatcher(...)
  • openSettings()
  • addListener('onlineNotificationAction', ...)
  • Interfaces

addWatcher(...)

addWatcher(options: WatcherOptions, callback: (position?: Location | undefined, error?: CallbackError | undefined) => void) => Promise<string>
ParamType
optionsWatcherOptions
callback(position?: Location, error?: CallbackError) => void

Returns: Promise<string>


removeWatcher(...)

removeWatcher(options: { id: string; }) => Promise<void>
ParamType
options{ id: string; }

openSettings()

openSettings() => Promise<void>

addListener('onlineNotificationAction', ...)

addListener(eventName: 'onlineNotificationAction', listenerFunc: (data: { isOnline: boolean; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when onlineNotificationAction set to true in addWatcher() and result received

Provides onlineNotificationAction result.

ParamType
eventName'onlineNotificationAction'
listenerFunc(data: { isOnline: boolean; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 2.0.2


Interfaces

WatcherOptions
PropType
backgroundMessagestring
backgroundTitlestring
requestPermissionsboolean
staleboolean
distanceFilternumber
onlineNotificationActionboolean
isOnlineboolean
actionOnlinestring
actionOfflinestring
Location
PropType
latitudenumber
longitudenumber
accuracynumber
altitudenumber | null
altitudeAccuracynumber | null
simulatedboolean
bearingnumber | null
speednumber | null
timenumber | null
CallbackError
PropType
codestring
PluginListenerHandle
PropType
remove() => Promise<void>

Keywords

FAQs

Package last updated on 30 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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