Skip to content

Commit ab78824

Browse files
authored
mock position detection for iOS15+ (#180)
1 parent 9dd1be0 commit ab78824

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ You need to include `NSLocationWhenInUseUsageDescription` and `NSLocationAlwaysA
108108

109109
In order to enable geolocation in the background, you need to include the 'NSLocationAlwaysUsageDescription' key in Info.plist and add location as a background mode in the 'Capabilities' tab in Xcode.
110110

111+
IOS >= 15 Positions will also contain a `mocked` boolean to indicate if position was created from a mock provider / software.
112+
113+
111114
### Android
112115

113116
To request access to location, you need to add the following line to your app's `AndroidManifest.xml`:

ios/RNCGeolocation.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,14 @@ - (void)locationManager:(CLLocationManager *)manager
369369
{
370370
// Create event
371371
CLLocation *location = locations.lastObject;
372+
373+
BOOL mocked = NO;
374+
if (@available(iOS 15.0, *)) {
375+
mocked = location.sourceInformation.isSimulatedBySoftware;
376+
}
377+
372378
_lastLocationEvent = @{
379+
@"mocked": @(mocked),
373380
@"coords": @{
374381
@"latitude": @(location.coordinate.latitude),
375382
@"longitude": @(location.coordinate.longitude),

0 commit comments

Comments
 (0)