Skip to content

Commit de29b69

Browse files
committed
Update README.md, example & typings
1 parent 0c15385 commit de29b69

File tree

3 files changed

+60
-48
lines changed

3 files changed

+60
-48
lines changed

Diff for: README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ When promise resolves, returns the status of the authorization.
7575
| maximumAge | `ms` | `INFINITY` | How long previous location will be cached |
7676
| accuracy | `object` | `--` | {<br/>&nbsp;&nbsp;&nbsp;android: [Link](docs/accuracy.md#android),<br/>&nbsp;&nbsp;&nbsp;ios: [Link](docs/accuracy.md#ios)<br/>}<br /><br /> If not provided or provided with invalid value, falls back to use `enableHighAccuracy` |
7777
| enableHighAccuracy | `bool` | `false` | Use high accuracy mode
78-
| distanceFilter | `m` | `0` | Minimum displacement in meters
78+
| distanceFilter | `m` | `100` | Minimum displacement in meters
7979
| showLocationDialog | `bool` | `true` | Whether to ask to enable location in Android (android only)
8080
| forceRequestLocation | `bool` | `false` | Force request location even after denying improve accuracy dialog (android only)
81+
| forceLocationManager | `bool` | `false` | If set to `true`, will use android's default LocationManager API (android only)
8182

8283
#### `watchPosition(successCallback, ?errorCallback, ?options)`
8384
- **successCallback**: Invoked with latest location info.
@@ -93,6 +94,7 @@ When promise resolves, returns the status of the authorization.
9394
| fastestInterval | `ms` | `5000` | Fastest rate at which your application will receive location updates, which might be faster than `interval` in some situations (for example, if other applications are triggering location updates) (android only)
9495
| showLocationDialog | `bool` | `true` | whether to ask to enable location in Android (android only)
9596
| forceRequestLocation | `bool` | `false` | Force request location even after denying improve accuracy dialog (android only)
97+
| forceLocationManager | `bool` | `false` | If set to `true`, will use android's default LocationManager API (android only)
9698
| useSignificantChanges | `bool` | false | Uses the battery-efficient native significant changes APIs to return locations. Locations will only be returned when the device detects a significant distance has been breached (iOS only)
9799
| showsBackgroundLocationIndicator | `bool` | false | This setting enables a blue bar or a blue pill in the status bar on iOS. When the app moves to the background, the system uses this property to determine whether to change the status bar appearance to indicate that location services are in use. Users can tap the indicator to return to your app. (iOS only)
98100

Diff for: example/src/App.js

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function App() {
2525
const [significantChanges, setSignificantChanges] = useState(false);
2626
const [observing, setObserving] = useState(false);
2727
const [foregroundService, setForegroundService] = useState(false);
28+
const [useLocationManager, setUseLocationManager] = useState(false);
2829
const [location, setLocation] = useState(null);
2930

3031
const watchId = useRef(null);
@@ -133,6 +134,7 @@ export default function App() {
133134
maximumAge: 10000,
134135
distanceFilter: 0,
135136
forceRequestLocation: forceLocation,
137+
forceLocationManager: useLocationManager,
136138
showLocationDialog: locationDialog,
137139
},
138140
);
@@ -170,6 +172,7 @@ export default function App() {
170172
interval: 5000,
171173
fastestInterval: 2000,
172174
forceRequestLocation: forceLocation,
175+
forceLocationManager: useLocationManager,
173176
showLocationDialog: locationDialog,
174177
useSignificantChanges: significantChanges,
175178
},
@@ -248,6 +251,13 @@ export default function App() {
248251
value={forceLocation}
249252
/>
250253
</View>
254+
<View style={styles.option}>
255+
<Text>Use Location Manager</Text>
256+
<Switch
257+
onValueChange={setUseLocationManager}
258+
value={useLocationManager}
259+
/>
260+
</View>
251261
<View style={styles.option}>
252262
<Text>Enable Foreground Service</Text>
253263
<Switch

Diff for: index.d.ts

+47-47
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
1-
declare module 'react-native-geolocation-service' {
2-
export type AuthorizationLevel = 'always' | 'whenInUse'
1+
declare module "react-native-geolocation-service" {
2+
export type AuthorizationLevel = "always" | "whenInUse";
33

4-
export type AuthorizationResult = 'disabled' | 'granted' | 'denied' | 'restricted'
4+
export type AuthorizationResult =
5+
| "disabled"
6+
| "granted"
7+
| "denied"
8+
| "restricted";
59

610
export type AccuracyIOS =
7-
| 'bestForNavigation'
8-
| 'best'
9-
| 'nearestTenMeters'
10-
| 'hundredMeters'
11-
| 'kilometer'
12-
| 'threeKilometers'
13-
| 'reduced';
14-
15-
export type AccuracyAndroid =
16-
| 'high'
17-
| 'balanced'
18-
| 'low'
19-
| 'passive';
11+
| "bestForNavigation"
12+
| "best"
13+
| "nearestTenMeters"
14+
| "hundredMeters"
15+
| "kilometer"
16+
| "threeKilometers"
17+
| "reduced";
18+
19+
export type AccuracyAndroid = "high" | "balanced" | "low" | "passive";
2020

2121
interface BaseOptions {
2222
accuracy?: {
2323
android?: AccuracyAndroid;
2424
ios?: AccuracyIOS;
2525
};
26-
enableHighAccuracy?: boolean
27-
distanceFilter?: number
28-
showLocationDialog?: boolean
29-
forceRequestLocation?: boolean
26+
enableHighAccuracy?: boolean;
27+
distanceFilter?: number;
28+
showLocationDialog?: boolean;
29+
forceRequestLocation?: boolean;
30+
forceLocationManager?: boolean;
3031
}
3132

3233
interface GeoOptions extends BaseOptions {
33-
timeout?: number
34-
maximumAge?: number
34+
timeout?: number;
35+
maximumAge?: number;
3536
}
3637

3738
interface GeoWatchOptions extends BaseOptions {
38-
interval?: number
39-
fastestInterval?: number
40-
useSignificantChanges?: boolean
41-
showsBackgroundLocationIndicator?: boolean
39+
interval?: number;
40+
fastestInterval?: number;
41+
useSignificantChanges?: boolean;
42+
showsBackgroundLocationIndicator?: boolean;
4243
}
4344

4445
export enum PositionError {
@@ -47,53 +48,52 @@ declare module 'react-native-geolocation-service' {
4748
TIMEOUT = 3,
4849
PLAY_SERVICE_NOT_AVAILABLE = 4,
4950
SETTINGS_NOT_SATISFIED = 5,
50-
INTERNAL_ERROR = -1
51+
INTERNAL_ERROR = -1,
5152
}
5253

5354
export interface GeoError {
54-
code: PositionError
55-
message: string
55+
code: PositionError;
56+
message: string;
5657
}
5758

5859
export interface GeoCoordinates {
59-
latitude: number
60-
longitude: number
61-
accuracy: number
62-
altitude: number | null
63-
heading: number | null
64-
speed: number | null
65-
altitudeAccuracy?: number | null
60+
latitude: number;
61+
longitude: number;
62+
accuracy: number;
63+
altitude: number | null;
64+
heading: number | null;
65+
speed: number | null;
66+
altitudeAccuracy?: number | null;
6667
}
6768

6869
export interface GeoPosition {
69-
coords: GeoCoordinates
70-
timestamp: number
70+
coords: GeoCoordinates;
71+
timestamp: number;
7172
mocked?: boolean;
72-
provider?: 'fused' | 'gps' | 'network' | 'passive';
73+
provider?: "fused" | "gps" | "network" | "passive";
7374
}
7475

75-
type SuccessCallback = (position: GeoPosition) => void
76+
type SuccessCallback = (position: GeoPosition) => void;
7677

77-
type ErrorCallback = (error: GeoError) => void
78+
type ErrorCallback = (error: GeoError) => void;
7879

7980
export function requestAuthorization(
8081
authorizationLevel: AuthorizationLevel
81-
): Promise<AuthorizationResult>
82+
): Promise<AuthorizationResult>;
8283

8384
export function getCurrentPosition(
8485
successCallback: SuccessCallback,
8586
errorCallback?: ErrorCallback,
8687
options?: GeoOptions
87-
): void
88+
): void;
8889

8990
export function watchPosition(
9091
successCallback: SuccessCallback,
9192
errorCallback?: ErrorCallback,
9293
options?: GeoWatchOptions
93-
): number
94+
): number;
9495

95-
export function clearWatch(watchID: number): void
96+
export function clearWatch(watchID: number): void;
9697

97-
export function stopObserving(): void
98+
export function stopObserving(): void;
9899
}
99-

0 commit comments

Comments
 (0)