Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-native-get-location
Advanced tools
⚛ Simple to use React Native library to get device location for Android and iOS.
⚛ Simple to use React Native library to get native device location for Android and iOS.
Install dependency package
yarn add react-native-get-location
Or
npm i -S react-native-get-location
Go to the folder your-project/ios and run pod install
, and you're done.
For Android you need to define the location permissions on AndroidManifest.xml
.
<!-- Define ACCESS_FINE_LOCATION if you will use enableHighAccuracy=true -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Define ACCESS_COARSE_LOCATION if you will use enableHighAccuracy=false -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
You need to define the permission NSLocationWhenInUseUsageDescription on Info.plist
.
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs to get your location...</string>
There is only one function that you need to use to get the user's current location.
import GetLocation from 'react-native-get-location'
GetLocation.getCurrentPosition({
enableHighAccuracy: true,
timeout: 60000,
})
.then(location => {
console.log(location);
})
.catch(error => {
const { code, message } = error;
console.warn(code, message);
})
For more details, see the Sample Project.
GetLocation.getCurrentPosition(LocationConfig)
Parameters:
LocationConfig
: Configuration object to determine how to get the user current location.Return:
Promise<
Location
>
: Promise thats resolve to a Location object.LocationConfig
Properties:
enableHighAccuracy
: Set true
to use 'fine location' (GPS) our false
to use 'course location' (Wifi, Bluetooth, 3G). Default: false
timeout
: The max time (in milliseconds) that you want to wait to receive a location. Default: 60000
(60 seconds)rationale?
: (Android only) See the React Native docs.Location
Properties:
latitude
: The latitude, in degrees.longitude
: The longitude, in degrees.altitude
: The altitude if available, in meters above the WGS 84 reference ellipsoid.accuracy
: The estimated horizontal accuracy of this location, radial, in meters.speed
: The speed if it is available, in meters/second over ground.time
: The UTC time of this fix, in milliseconds since January 1, 1970.bearing
: (Android only) The bearing, in degrees.provider
: (Android only) The name of the provider that generated this fix.verticalAccuracy
: (iOS only) The vertical accuracy of the location. Negative if the altitude is invalid.course
: (iOS only) The course of the location in degrees true North. Negative if course is invalid. (0.0 - 359.9 degrees, 0 being true North)Code | Message |
---|---|
CANCELLED | Location cancelled by user or by another request |
UNAVAILABLE | Location service is disabled or unavailable |
TIMEOUT | Location request timed out |
UNAUTHORIZED | Authorization denied |
New features, bug fixes and improvements are welcome! For questions and suggestions use the issues.
The MIT License (MIT)
Copyright (c) 2019 Douglas Nassif Roma Junior
See the full license file.
FAQs
⚛ Simple to use React Native library to get device location for Android and iOS.
We found that react-native-get-location demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.