-
Notifications
You must be signed in to change notification settings - Fork 239
/
Copy pathNativeRNCGeolocation.ts
67 lines (60 loc) · 1.77 KB
/
NativeRNCGeolocation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
export type GeolocationConfiguration = {
skipPermissionRequests: boolean;
authorizationLevel?: 'always' | 'whenInUse' | 'auto';
locationProvider?: 'playServices' | 'android' | 'auto';
enableBackgroundLocationUpdates?: boolean;
showsBackgroundLocationIndicator?: boolean;
};
export type GeolocationOptions = {
timeout?: number;
maximumAge?: number;
enableHighAccuracy?: boolean;
distanceFilter?: number;
useSignificantChanges?: boolean;
interval?: number;
fastestInterval?: number;
};
export type GeolocationResponse = {
coords: {
latitude: number;
longitude: number;
altitude: number | null;
accuracy: number;
altitudeAccuracy: number | null;
heading: number | null;
speed: number | null;
};
timestamp: number;
};
export type GeolocationError = {
code: number;
message: string;
PERMISSION_DENIED: number;
POSITION_UNAVAILABLE: number;
TIMEOUT: number;
};
export interface Spec extends TurboModule {
setConfiguration(config: {
skipPermissionRequests: boolean;
authorizationLevel?: string;
enableBackgroundLocationUpdates?: string;
showsBackgroundLocationIndicator?: string;
}): void;
requestAuthorization(
success: () => void,
error: (error: GeolocationError) => void
): void;
getCurrentPosition(
options: GeolocationOptions,
position: (position: GeolocationResponse) => void,
error: (error: GeolocationError) => void
): void;
startObserving(options: GeolocationOptions): void;
stopObserving(): void;
// RCTEventEmitter
addListener: (eventName: string) => void;
removeListeners: (count: number) => void;
}
export default TurboModuleRegistry.getEnforcing<Spec>('RNCGeolocation');