react-native-location-manager-ios
React Native Location Manager Bridge for iOS
This module is intended for advanced usage, if you only need basic geolocation functionality you will be better with React Native Geolocation module.
Installation
yarn add react-native-location-manager-ios
Automatic linking
react-native link react-native-location-manager-ios
Manual linking
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-location-manager-ios
➜ios
and addRCTLocationManagerIOS.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRCTLocationManagerIOS.a
to your project'sBuild Phases
➜Link Binary With Libraries
Usage Description
Add to your Info.plist
apropriate *UsageDescription
keys with a string value explaining to the
user how the app uses location data. Please see official documentation
NSLocationWhenInUseUsageDescriptionSome descriptionNSLocationAlwaysUsageDescriptionSome descriptionNSLocationAlwaysAndWhenInUseUsageDescriptionSome description
Usage
;
API
Events
Event names are available under LocationManagerIOS.Events
object.
const subscription = LocationManagerIOS;// ...subscription;
See CLLocationManagerDelegate
for in-depth details.
Event | Listener Arguments | Notes |
---|---|---|
didUpdateLocations |
locations: Array<Location> |
|
didFailWithError |
error: Error |
|
didFinishDeferredUpdatesWithError |
error: Error |
|
didPauseLocationUpdates |
||
didResumeLocationUpdates |
||
didUpdateHeading |
heading: Heading |
|
didEnterRegion |
region: Region |
|
didExitRegion |
region: Region |
|
didDetermineStateForRegion |
{ region: Region, state: RegionState } |
|
monitoringDidFailForRegion |
{ region: Region, error: Error } |
|
didStartMonitoringForRegion |
region: Region |
|
didRangeBeaconsInRegion |
{ beacons: Array<Beacon>, region: BeaconRegion } |
|
rangingBeaconsDidFailForRegion |
{ region: BeaconRegion, error: Error } |
|
didVisit |
visit: Visit |
|
didChangeAuthorizationStatus |
status: AuthorizationStatus |
Enums
LocationManagerIOS;
Enum | Keys |
---|---|
AuthorizationStatus |
NotDetermined , Restricted , Denied , AuthorizedAlways , AuthorizedWhenInUse |
LocationAccuracy |
BestForNavigation , Best , NearestTenMeters , HundredMeters , Kilometer , ThreeKilometers |
DistanceFilter |
None |
ActivityType |
Other , AutomotiveNavigation , Fitness , OtherNavigation |
DeviceOrientation |
Unknown , Portrait , PortraitUpsideDown , LandscapeLeft , LandscapeRight , FaceUp , FaceDown |
RegionState |
Unknown , Inside , Outside |
Proximity |
Unknown , Immediate , Near , Far |
Error |
LocationUnknown , Denied , Network , HeadingFailure , RegionMonitoringDenied , RegionMonitoringFailure , RegionMonitoringSetupDelayed , RegionMonitoringResponseDelayed , GeocodeFoundNoResult , GeocodeFoundPartialResult , GeocodeCanceled , DeferredFailed , DeferredNotUpdatingLocation , DeferredAccuracyTooLow , DeferredDistanceFiltered , DeferredCanceled , RangingUnavailable , RangingFailure |
Properties
Property getters return a promise resolved with the property value.
See CLLocationManager
for in-depth details.
const monitoredRegions = await LocationManagerIOSmonitoredRegions;monitoredRegions const distanceFilter = await LocationManagerIOSdistanceFilter;if distanceFilter === LocationManagerIOSDistanceFilterNone LocationManagerIOSdistanceFilter = 3; LocationManagerIOSdesiredAccuracy = LocationManagerIOSLocationAccuracyBestForNavigation; LocationManagerIOSactivityType = LocationManagerIOSActivityTypeAutomotiveNavigation;
Property | Type | Notes |
---|---|---|
pausesLocationUpdatesAutomatically |
bool |
|
allowsBackgroundLocationUpdates |
bool |
|
showsBackgroundLocationIndicator |
bool |
|
distanceFilter |
double |
|
desiredAccuracy |
double |
|
activityType |
ActivityType |
|
headingFilter |
double |
|
headingOrientation |
DeviceOrientation |
|
maximumRegionMonitoringDistance |
double |
readonly |
monitoredRegions |
Array<CircularRegion> |
readonly |
rangedRegions |
Array<BeaconRegion> |
readonly |
location |
Location |
readonly |
heading |
Heading |
readonly |
Methods
Non void
methods return a promise which will resolve to the according type.
See CLLocationManager
for in-depth details.
Types
type Error code: int domain: string
type Location altitude: double horizontalAccuracy: double verticalAccuracy: double speed: double course: double timestamp: double // precision is to the millisecond coordinate: Coordinate
type Coordinate latitude: double longitude: double
type Region identifier: string notifyOnEntry: bool notifyOnExit: bool
type CircularRegion identifier: string radius: double center: Coordinate notifyOnEntry: bool notifyOnExit: bool
type BeaconRegion identifier: string proximityUUID: string major: int minor: int notifyOnEntry: bool notifyOnExit: bool
type Beacon proximityUUID: string major: int minor: int proximity: LocationManagerIOSProximity accuracy: double rssi: long
type Visit horizontalAccuracy: double arrivalDate: double // precision is to the millisecond departureDate: double // precision is to the millisecond coordinate: Coordinate
type Heading magneticHeading: double trueHeading: double headingAccuracy: double timestamp: double // precision is to the millisecond x: double y: double z: double
Custom
LocationManagerIOS.stopMonitoringForAllRegions()
Native implementation for:
const monitoredRegions = await LocationManagerIOSmonitoredRegions;monitoredRegions ;
LocationManagerIOS.stopRangingBeaconsInAllRegions()
Native implementation for:
const rangedRegions = await LocationManagerIOSrangedRegions;rangedRegions ;