
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
nativescript-geolocation
Advanced tools
Provides API for getting and monitoring location for NativeScript app.
Geolocation plugin to use for getting current location, monitor movement, etc.
In Command prompt / Terminal navigate to your application root folder and run:
tns plugin add nativescript-geolocation
The best way to explore the usage of the plugin is to inspect the demo app in the plugin's root folder.
In demo
folder you can find the usage of the plugin for TypeScript non-Angular application. Refer to demo/app/main-page.ts
.
In short here are the steps:
TypeScript
import * as geolocation from "nativescript-geolocation";
import { Accuracy } from "ui/enums"; // used to describe at what accuracy the location should be get
Javascript
var geolocation = require("nativescript-geolocation");
geolocation.enableLocationRequest();
// Get current location with high accuracy
geolocation.getCurrentLocation({ desiredAccuracy: Accuracy.high, maximumAge: 5000, timeout: 20000 })
Property | Default | Description |
---|---|---|
latitude | - | The latitude of the geolocation, in degrees. |
longitude | - | The longitude of the geolocation, in degrees. |
altitude | - | The altitude (if available), in meters above sea level. |
horizontalAccuracy | - | The horizontal accuracy, in meters. |
verticalAccuracy | - | The vertical accuracy, in meters. |
speed | - | The speed, in meters/second over ground. |
timestamp | - | The time at which this location was determined. |
Property | Default | Description |
---|---|---|
desiredAccuracy? | Accuracy.high | Specifies desired accuracy in meters. |
updateDistance | iOS - no filter | Update distance filter in meters. Specifies how often to update the location (ignored on Android). |
updateTime | 1 minute | Interval between location updates, in milliseconds (ignored on iOS). Read more in Google document. |
minimumUpdateTime | 5 secs | Minimum time interval between location updates, in milliseconds (ignored on iOS). Read more in Google document. |
maximumAge | - | How old locations to receive in ms. |
timeout | 5 minutes | How long to wait for a location in ms. |
iosAllowsBackgroundLocationUpdates | false | If enabled, UIBackgroundModes key in info.plist is required (check the hint below). Allow the application to receive location updates in background (ignored on Android) |
iosPausesLocationUpdatesAutomatically | true | Allow deactivation of the automatic pause of location updates (ignored on Android) |
If iosAllowsBackgroundLocationUpdates is set to true, the following code is required in the info.plist file:
<key>UIBackgroundModes</key> <array> <string>location</string> </array>
Method | Returns | Description |
---|---|---|
getCurrentLocation(options: Options) | Promise | Get current location applying the specified options (if any). |
watchLocation(successCallback: successCallbackType, errorCallback: errorCallbackType, options: Options) | number | Monitor for location change. |
clearWatch(watchId: number) | void | Stop monitoring for location change. Parameter expected is the watchId returned from watchLocation . |
enableLocationRequest(always?: boolean) | Promise<void> | Ask for permissions to use location services. The option always is application for iOS only. Read more about its usage . |
isEnabled | Promise<boolean> | Resolves true or false based on the location services availability. |
distance(loc1: Location, loc2: Location) | number | Calculate the distance between two locations. Returns the distance in meters. |
If you have installed multiple plugins that use the Google Play Services you might run into version conflicts.
In order to fix this you might pin the version number in your app/App_Resources/Android/app.gradle
file:
android {
// other stuff here
project.ext {
googlePlayServicesVersion = "11.2.+"
}
}
Apache License Version 2.0, January 2004
FAQs
Provides API for getting and monitoring location for NativeScript app.
The npm package nativescript-geolocation receives a total of 18 weekly downloads. As such, nativescript-geolocation popularity was classified as not popular.
We found that nativescript-geolocation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.