expo-location 58.0.13 → 58.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/android/build.gradle +2 -2
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/expo/modules/location/next/LocationModuleNext.kt +189 -10
- package/android/src/main/java/expo/modules/location/next/LocationPermissions.kt +65 -0
- package/android/src/main/java/expo/modules/location/next/LocationRecords.kt +91 -2
- package/android/src/main/java/expo/modules/location/next/LocationTaskConsumer.kt +205 -0
- package/android/src/main/java/expo/modules/location/next/WatchPosition.kt +8 -6
- package/android/src/main/java/expo/modules/location/next/locationForegroundService/BackgroundSessionOptions.kt +62 -0
- package/android/src/main/java/expo/modules/location/next/locationForegroundService/BackgroundSessionTypes.kt +32 -0
- package/android/src/main/java/expo/modules/location/next/locationForegroundService/ForegroundServiceExceptions.kt +53 -0
- package/android/src/main/java/expo/modules/location/next/locationForegroundService/LocationForegroundService.kt +142 -0
- package/android/src/main/java/expo/modules/location/next/locationForegroundService/ServiceNotification.kt +64 -0
- package/android/src/main/java/expo/modules/location/next/locationProviders/AndroidLocationProvider.kt +115 -7
- package/android/src/main/java/expo/modules/location/next/locationProviders/FallbackLocationProvider.kt +12 -3
- package/android/src/main/java/expo/modules/location/next/locationProviders/GmsLocationProvider.kt +79 -0
- package/android/src/main/java/expo/modules/location/next/locationProviders/LocationProvider.kt +48 -0
- package/android/src/main/java/expo/modules/location/taskConsumers/LocationTaskConsumer.kt +6 -0
- package/build/next/index.d.ts +1 -1
- package/build/next/index.js.map +1 -1
- package/build/next/js/LocationProvider.d.ts +35 -0
- package/build/next/js/LocationProvider.js +35 -6
- package/build/next/js/LocationProvider.js.map +1 -1
- package/build/next/js/LocationUpdatesHandle.d.ts +45 -7
- package/build/next/js/LocationUpdatesHandle.js +43 -7
- package/build/next/js/LocationUpdatesHandle.js.map +1 -1
- package/build/next/js/Permissions.d.ts +63 -0
- package/build/next/js/Permissions.js +63 -6
- package/build/next/js/Permissions.js.map +1 -1
- package/build/next/js/PositionWatchHandle.d.ts +78 -0
- package/build/next/js/PositionWatchHandle.js +78 -11
- package/build/next/js/PositionWatchHandle.js.map +1 -1
- package/build/next/js/getPosition.d.ts +26 -1
- package/build/next/js/getPosition.js +26 -2
- package/build/next/js/getPosition.js.map +1 -1
- package/build/next/js/locationServices.d.ts +29 -0
- package/build/next/js/locationServices.js +29 -3
- package/build/next/js/locationServices.js.map +1 -1
- package/build/next/types/LocationTask.types.d.ts +20 -0
- package/build/next/types/LocationTask.types.js +5 -0
- package/build/next/types/LocationTask.types.js.map +1 -0
- package/build/next/types/Permissions.types.d.ts +68 -0
- package/build/next/types/Permissions.types.js +51 -9
- package/build/next/types/Permissions.types.js.map +1 -1
- package/build/next/types/Position.types.d.ts +203 -2
- package/build/next/types/Position.types.js +51 -7
- package/build/next/types/Position.types.js.map +1 -1
- package/build/next/types/index.d.ts +1 -0
- package/build/next/types/index.js +1 -0
- package/build/next/types/index.js.map +1 -1
- package/ios/Providers/LocationsStreamer.swift +10 -4
- package/ios/TaskConsumers/EXGeofencingTaskConsumer.m +16 -1
- package/ios/next/LocationModuleNext.swift +4 -0
- package/ios/next/LocationNextExceptions.swift +0 -8
- package/ios/next/LocationUpdatesHandle/LocationUpdatesHandle.swift +6 -2
- package/ios/next/Position/LocationUpdateDiagnostics.swift +0 -3
- package/ios/next/Position/PositionUpdatesCompatibilitySource.swift +9 -1
- package/ios/next/Position/PositionUpdatesLiveSource.swift +5 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.13/expo.modules.location-58.0.13.module → 58.0.15/expo.modules.location-58.0.15.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.13/expo.modules.location-58.0.13.pom → 58.0.15/expo.modules.location-58.0.15.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha512 +1 -0
- package/package.json +2 -2
- package/plugin/build/withLocation.js +2 -0
- package/plugin/build/withLocation.js.map +1 -1
- package/plugin/src/withLocation.ts +2 -0
- package/src/next/index.ts +1 -0
- package/src/next/js/LocationProvider.ts +35 -0
- package/src/next/js/LocationUpdatesHandle.ts +45 -8
- package/src/next/js/Permissions.ts +63 -0
- package/src/next/js/PositionWatchHandle.ts +78 -0
- package/src/next/js/getPosition.ts +29 -2
- package/src/next/js/locationServices.ts +29 -0
- package/src/next/types/LocationTask.types.ts +22 -0
- package/src/next/types/Permissions.types.ts +68 -0
- package/src/next/types/Position.types.ts +203 -2
- package/src/next/types/index.ts +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha512 +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/LocationUpdatesHandle.ts"],"sourcesContent":[null],"names":["NativeLocationUpdatesHandle","DEFAULT_LOCATION_TASK_NAME","LocationUpdatesHandle","nativeHandle","taskName","withProfile","profile","start","stop","hasStarted","defineLocationTask","onPosition","onError","requireTaskManager","defineTask","data","error","require","Error"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["next/js/LocationUpdatesHandle.ts"],"sourcesContent":[null],"names":["NativeLocationUpdatesHandle","DEFAULT_LOCATION_TASK_NAME","LocationUpdatesHandle","nativeHandle","taskName","withProfile","profile","start","stop","hasStarted","defineLocationTask","onPosition","onError","requireTaskManager","defineTask","data","error","require","Error"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,YAAY;AAIxD,MAAMC,6BAA6B;AAEnC;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC;IACMC,aAA+C;IAEhE;;;GAGC,GACD,YAAYC,WAAmBH,0BAA0B,CAAE;QACzD,IAAI,CAACE,YAAY,GAAG,IAAIH,4BAA4BI;IACtD;IAEA;;;;;GAKC,GACDC,YAAYC,OAAwB,EAAQ;QAC1C,IAAI,CAACH,YAAY,CAACE,WAAW,CAACC;QAC9B,OAAO,IAAI;IACb;IAEA;;;;;GAKC,GACDC,QAAuB;QACrB,OAAO,IAAI,CAACJ,YAAY,CAACI,KAAK;IAChC;IAEA;;GAEC,GACDC,OAAsB;QACpB,OAAO,IAAI,CAACL,YAAY,CAACK,IAAI;IAC/B;IAEA;;;GAGC,GACDC,aAA+B;QAC7B,OAAO,IAAI,CAACN,YAAY,CAACM,UAAU;IACrC;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,mBAAmB,EACjCN,WAAWH,0BAA0B,EACrCU,UAAU,EACVC,OAAO,EACa;IACpBC,qBAAqBC,UAAU,CAAWV,UAAU,OAAO,EAAEW,IAAI,EAAEC,KAAK,EAAE;QACxE,IAAIA,OAAO;YACTJ,UAAUI;YACV;QACF;QACAL,WAAWI;IACb;AACF;AAEA,SAASF;IACP,IAAI;QACF,OAAOI,QAAQ;IACjB,EAAE,OAAM;QACN,MAAM,IAAIC,MACR;IAEJ;AACF"}
|
|
@@ -1,7 +1,70 @@
|
|
|
1
1
|
import type { LocationPermissionResponse, RequestPermissionsOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Checks the foreground location permission without asking the user.
|
|
4
|
+
*
|
|
5
|
+
* @return A promise that resolves to the current permission, including its scope and accuracy.
|
|
6
|
+
*/
|
|
2
7
|
export declare function getForegroundPermissions(): Promise<LocationPermissionResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Asks the user for permission to read the location while the app is in the foreground.
|
|
10
|
+
* Shows the system dialog only while the permission is undetermined; afterwards it resolves with
|
|
11
|
+
* the current state, so check `canAskAgain` to know whether the user has to go to the system
|
|
12
|
+
* settings.
|
|
13
|
+
*
|
|
14
|
+
* See [Request the precise location](#request-the-precise-location) and
|
|
15
|
+
* [Handle a denied permission](#handle-a-denied-permission).
|
|
16
|
+
*
|
|
17
|
+
* @param options The accuracy to ask for.
|
|
18
|
+
* @return A promise that resolves to the permission after the user answered.
|
|
19
|
+
*/
|
|
3
20
|
export declare function requestForegroundPermissions(options?: RequestPermissionsOptions): Promise<LocationPermissionResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Checks the background location permission without asking the user.
|
|
23
|
+
*
|
|
24
|
+
* @return A promise that resolves to the current permission. `scope` is `always` when it is
|
|
25
|
+
* granted.
|
|
26
|
+
*/
|
|
4
27
|
export declare function getBackgroundPermissions(): Promise<LocationPermissionResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Asks the user for permission to read the location while the app is in the background.
|
|
30
|
+
* On Android, it requires the foreground permission first. On iOS, answering
|
|
31
|
+
* **Keep Only While Using** resolves with `status` `denied` and `scope` `whenInUse`.
|
|
32
|
+
*
|
|
33
|
+
* See [Request the background permission](#request-the-background-permission).
|
|
34
|
+
*
|
|
35
|
+
* @param options The accuracy to ask for
|
|
36
|
+
* @return A promise that resolves to the permission after the user answered.
|
|
37
|
+
*/
|
|
5
38
|
export declare function requestBackgroundPermissions(options?: RequestPermissionsOptions): Promise<LocationPermissionResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Checks or requests the foreground location permission from a component.
|
|
41
|
+
* See [Request the precise location](#request-the-precise-location).
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const [permission, requestPermission] = useForegroundLocationPermissions();
|
|
46
|
+
*
|
|
47
|
+
* if (!permission?.granted) {
|
|
48
|
+
* return <Button title="Allow location" onPress={requestPermission} />;
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
6
52
|
export declare const useForegroundLocationPermissions: (options?: import("expo-modules-core").PermissionHookOptions<RequestPermissionsOptions> | undefined) => [LocationPermissionResponse | null, () => Promise<LocationPermissionResponse>, () => Promise<LocationPermissionResponse>];
|
|
53
|
+
/**
|
|
54
|
+
* Checks or requests the background location permission from a component.
|
|
55
|
+
* See [Request the background permission](#request-the-background-permission).
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* const [foreground, requestForeground] = useForegroundLocationPermissions();
|
|
60
|
+
* const [background, requestBackground] = useBackgroundLocationPermissions();
|
|
61
|
+
*
|
|
62
|
+
* if (!foreground?.granted) {
|
|
63
|
+
* return <Button title="Allow location" onPress={requestForeground} />;
|
|
64
|
+
* }
|
|
65
|
+
* if (background?.scope !== LocationScope.ALWAYS) {
|
|
66
|
+
* return <Button title="Allow background location" onPress={requestBackground} />;
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
7
70
|
export declare const useBackgroundLocationPermissions: (options?: import("expo-modules-core").PermissionHookOptions<RequestPermissionsOptions> | undefined) => [LocationPermissionResponse | null, () => Promise<LocationPermissionResponse>, () => Promise<LocationPermissionResponse>];
|
|
@@ -1,22 +1,79 @@
|
|
|
1
1
|
import { createPermissionHook } from 'expo-modules-core';
|
|
2
2
|
import { NativeLocationModuleNext } from '../native';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Checks the foreground location permission without asking the user.
|
|
5
|
+
*
|
|
6
|
+
* @return A promise that resolves to the current permission, including its scope and accuracy.
|
|
7
|
+
*/ export async function getForegroundPermissions() {
|
|
4
8
|
return NativeLocationModuleNext.getForegroundPermissions();
|
|
5
9
|
}
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Asks the user for permission to read the location while the app is in the foreground.
|
|
12
|
+
* Shows the system dialog only while the permission is undetermined; afterwards it resolves with
|
|
13
|
+
* the current state, so check `canAskAgain` to know whether the user has to go to the system
|
|
14
|
+
* settings.
|
|
15
|
+
*
|
|
16
|
+
* See [Request the precise location](#request-the-precise-location) and
|
|
17
|
+
* [Handle a denied permission](#handle-a-denied-permission).
|
|
18
|
+
*
|
|
19
|
+
* @param options The accuracy to ask for.
|
|
20
|
+
* @return A promise that resolves to the permission after the user answered.
|
|
21
|
+
*/ export async function requestForegroundPermissions(options) {
|
|
7
22
|
return NativeLocationModuleNext.requestForegroundPermissions(options);
|
|
8
23
|
}
|
|
9
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Checks the background location permission without asking the user.
|
|
26
|
+
*
|
|
27
|
+
* @return A promise that resolves to the current permission. `scope` is `always` when it is
|
|
28
|
+
* granted.
|
|
29
|
+
*/ export async function getBackgroundPermissions() {
|
|
10
30
|
return NativeLocationModuleNext.getBackgroundPermissions();
|
|
11
31
|
}
|
|
12
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Asks the user for permission to read the location while the app is in the background.
|
|
34
|
+
* On Android, it requires the foreground permission first. On iOS, answering
|
|
35
|
+
* **Keep Only While Using** resolves with `status` `denied` and `scope` `whenInUse`.
|
|
36
|
+
*
|
|
37
|
+
* See [Request the background permission](#request-the-background-permission).
|
|
38
|
+
*
|
|
39
|
+
* @param options The accuracy to ask for
|
|
40
|
+
* @return A promise that resolves to the permission after the user answered.
|
|
41
|
+
*/ export async function requestBackgroundPermissions(options) {
|
|
13
42
|
return NativeLocationModuleNext.requestBackgroundPermissions(options);
|
|
14
43
|
}
|
|
15
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Checks or requests the foreground location permission from a component.
|
|
46
|
+
* See [Request the precise location](#request-the-precise-location).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* const [permission, requestPermission] = useForegroundLocationPermissions();
|
|
51
|
+
*
|
|
52
|
+
* if (!permission?.granted) {
|
|
53
|
+
* return <Button title="Allow location" onPress={requestPermission} />;
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/ export const useForegroundLocationPermissions = createPermissionHook({
|
|
16
57
|
getMethod: getForegroundPermissions,
|
|
17
58
|
requestMethod: requestForegroundPermissions
|
|
18
59
|
});
|
|
19
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Checks or requests the background location permission from a component.
|
|
62
|
+
* See [Request the background permission](#request-the-background-permission).
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* const [foreground, requestForeground] = useForegroundLocationPermissions();
|
|
67
|
+
* const [background, requestBackground] = useBackgroundLocationPermissions();
|
|
68
|
+
*
|
|
69
|
+
* if (!foreground?.granted) {
|
|
70
|
+
* return <Button title="Allow location" onPress={requestForeground} />;
|
|
71
|
+
* }
|
|
72
|
+
* if (background?.scope !== LocationScope.ALWAYS) {
|
|
73
|
+
* return <Button title="Allow background location" onPress={requestBackground} />;
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/ export const useBackgroundLocationPermissions = createPermissionHook({
|
|
20
77
|
getMethod: getBackgroundPermissions,
|
|
21
78
|
requestMethod: requestBackgroundPermissions
|
|
22
79
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/Permissions.ts"],"sourcesContent":[null],"names":["createPermissionHook","NativeLocationModuleNext","getForegroundPermissions","requestForegroundPermissions","options","getBackgroundPermissions","requestBackgroundPermissions","useForegroundLocationPermissions","getMethod","requestMethod","useBackgroundLocationPermissions"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,oBAAoB;AAEzD,SAASC,wBAAwB,QAAQ,YAAY;AAGrD,OAAO,eAAeC;IACpB,OAAOD,yBAAyBC,wBAAwB;AAC1D;AAEA,OAAO,eAAeC,6BACpBC,OAAmC;IAEnC,OAAOH,yBAAyBE,4BAA4B,CAACC;AAC/D;AAEA,OAAO,eAAeC;IACpB,OAAOJ,yBAAyBI,wBAAwB;AAC1D;AAEA,OAAO,eAAeC,6BACpBF,OAAmC;IAEnC,OAAOH,yBAAyBK,4BAA4B,CAACF;AAC/D;AAEA,OAAO,MAAMG,mCAAmCP,qBAAqB;IACnEQ,WAAWN;IACXO,eAAeN;AACjB,GAAG;AAEH,OAAO,MAAMO,mCAAmCV,qBAAqB;IACnEQ,WAAWH;IACXI,eAAeH;AACjB,GAAG"}
|
|
1
|
+
{"version":3,"sources":["next/js/Permissions.ts"],"sourcesContent":[null],"names":["createPermissionHook","NativeLocationModuleNext","getForegroundPermissions","requestForegroundPermissions","options","getBackgroundPermissions","requestBackgroundPermissions","useForegroundLocationPermissions","getMethod","requestMethod","useBackgroundLocationPermissions"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,oBAAoB;AAEzD,SAASC,wBAAwB,QAAQ,YAAY;AAGrD;;;;CAIC,GACD,OAAO,eAAeC;IACpB,OAAOD,yBAAyBC,wBAAwB;AAC1D;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC,6BACpBC,OAAmC;IAEnC,OAAOH,yBAAyBE,4BAA4B,CAACC;AAC/D;AAEA;;;;;CAKC,GACD,OAAO,eAAeC;IACpB,OAAOJ,yBAAyBI,wBAAwB;AAC1D;AAEA;;;;;;;;;CASC,GACD,OAAO,eAAeC,6BACpBF,OAAmC;IAEnC,OAAOH,yBAAyBK,4BAA4B,CAACF;AAC/D;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMG,mCAAmCP,qBAAqB;IACnEQ,WAAWN;IACXO,eAAeN;AACjB,GAAG;AAEH;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMO,mCAAmCV,qBAAqB;IACnEQ,WAAWH;IACXI,eAAeH;AACjB,GAAG"}
|
|
@@ -1,16 +1,94 @@
|
|
|
1
1
|
import type { EventSubscription } from 'expo';
|
|
2
2
|
import { LocationProfile } from '../types';
|
|
3
3
|
import type { Position, PositionWatchError, PositionWatchStatus, WatchPositionParams } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Controls a running position watcher. Use `watchPosition()` to create one.
|
|
6
|
+
*
|
|
7
|
+
* See [Show live position on a screen](#show-live-position-on-a-screen).
|
|
8
|
+
*/
|
|
4
9
|
export declare class PositionWatchHandle {
|
|
5
10
|
private readonly nativeHandle;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a native watcher without a listener. On Android, it starts when the first listener is
|
|
13
|
+
* added. On iOS, it starts right away. Prefer `watchPosition`, which also attaches the listener.
|
|
14
|
+
*
|
|
15
|
+
* @param profile The use case that selects the accuracy and the update rate.
|
|
16
|
+
*/
|
|
6
17
|
constructor(profile?: LocationProfile);
|
|
18
|
+
/**
|
|
19
|
+
* Stops delivering positions and releases the system request, keeping the watcher for `resume()`.
|
|
20
|
+
*/
|
|
7
21
|
pause(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Requests positions again after `pause()`.
|
|
24
|
+
*
|
|
25
|
+
* @return `false` when the provider rejects the request right away. Later failures, including
|
|
26
|
+
* every failure on iOS and with Google Play services, arrive through `onError`.
|
|
27
|
+
* @throws After `dispose()`, like every other call on a disposed handle.
|
|
28
|
+
*/
|
|
8
29
|
resume(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Stages a new profile for the watcher. It has no effect until `restart()`.
|
|
32
|
+
*
|
|
33
|
+
* @return The same handle, for chaining.
|
|
34
|
+
*/
|
|
9
35
|
withProfile(profile: LocationProfile): this;
|
|
36
|
+
/**
|
|
37
|
+
* Stages the time between two delivered positions, in seconds. It has no effect until
|
|
38
|
+
* `restart()`. Positions arrive less often when the system has no new fix. `0` delivers every
|
|
39
|
+
* position the system produces.
|
|
40
|
+
*
|
|
41
|
+
* On Android, it replaces the update interval the profile requests from the provider. On iOS, the
|
|
42
|
+
* system decides the rate and positions that arrive sooner than the interval are dropped.
|
|
43
|
+
*
|
|
44
|
+
* @param intervalSeconds A finite number of seconds, `0` or greater. Throws for other values.
|
|
45
|
+
* @return The same handle, for chaining.
|
|
46
|
+
*/
|
|
10
47
|
withInterval(intervalSeconds: number): this;
|
|
48
|
+
/**
|
|
49
|
+
* Subscribes again with the settings staged by `withProfile()` and `withInterval()`.
|
|
50
|
+
* It does not resume a paused watcher.
|
|
51
|
+
*
|
|
52
|
+
* @return `false` when the provider rejects the request right away. Later failures arrive through
|
|
53
|
+
* `onError`.
|
|
54
|
+
*/
|
|
11
55
|
restart(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Reads the current flags of the watcher.
|
|
58
|
+
*/
|
|
12
59
|
status(): PositionWatchStatus;
|
|
60
|
+
/**
|
|
61
|
+
* Removes all listeners and releases the native watcher.
|
|
62
|
+
*/
|
|
13
63
|
dispose(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribes to the position and error events. One watcher can have multiple listeners.
|
|
66
|
+
*
|
|
67
|
+
* @param onPosition Called when a new position is delivered.
|
|
68
|
+
* @param onError Called when an error occurs.
|
|
69
|
+
* @return A subscription object with a `remove` method that stops listening for changes.
|
|
70
|
+
*/
|
|
14
71
|
addListener(onPosition: (position: Position) => void, onError?: (error: PositionWatchError) => void): EventSubscription;
|
|
15
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Starts watching the position and returns the handle that controls the watcher.
|
|
75
|
+
*
|
|
76
|
+
* See [Show live position on a screen](#show-live-position-on-a-screen).
|
|
77
|
+
*
|
|
78
|
+
* @param options The profile and the callbacks for positions and errors.
|
|
79
|
+
* @return The handle for controlling the watcher.
|
|
80
|
+
* @throws When the foreground permission is not granted, when location services are off (iOS), or
|
|
81
|
+
* when the selected provider cannot watch the position (Android).
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const watcher = Location.watchPosition({
|
|
85
|
+
* profile: LocationProfile.FITNESS,
|
|
86
|
+
* onPosition: (position) => console.log(position.coordinates),
|
|
87
|
+
* onError: (error) => console.warn(error.code, error.message),
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* // When the positions are no longer needed:
|
|
91
|
+
* watcher.dispose();
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
16
94
|
export declare function watchPosition({ profile, onPosition, onError, }: WatchPositionParams): PositionWatchHandle;
|
|
@@ -1,35 +1,82 @@
|
|
|
1
1
|
import { NativeLocationModuleNext } from '../native';
|
|
2
2
|
import { LocationProfile } from '../types';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Controls a running position watcher. Use `watchPosition()` to create one.
|
|
5
|
+
*
|
|
6
|
+
* See [Show live position on a screen](#show-live-position-on-a-screen).
|
|
7
|
+
*/ export class PositionWatchHandle {
|
|
4
8
|
nativeHandle;
|
|
5
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates a native watcher without a listener. On Android, it starts when the first listener is
|
|
11
|
+
* added. On iOS, it starts right away. Prefer `watchPosition`, which also attaches the listener.
|
|
12
|
+
*
|
|
13
|
+
* @param profile The use case that selects the accuracy and the update rate.
|
|
14
|
+
*/ constructor(profile = LocationProfile.DEFAULT){
|
|
6
15
|
this.nativeHandle = NativeLocationModuleNext.watchPosition(profile);
|
|
7
16
|
}
|
|
8
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Stops delivering positions and releases the system request, keeping the watcher for `resume()`.
|
|
19
|
+
*/ pause() {
|
|
9
20
|
this.nativeHandle.pause();
|
|
10
21
|
}
|
|
11
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Requests positions again after `pause()`.
|
|
24
|
+
*
|
|
25
|
+
* @return `false` when the provider rejects the request right away. Later failures, including
|
|
26
|
+
* every failure on iOS and with Google Play services, arrive through `onError`.
|
|
27
|
+
* @throws After `dispose()`, like every other call on a disposed handle.
|
|
28
|
+
*/ resume() {
|
|
12
29
|
return this.nativeHandle.resume();
|
|
13
30
|
}
|
|
14
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Stages a new profile for the watcher. It has no effect until `restart()`.
|
|
33
|
+
*
|
|
34
|
+
* @return The same handle, for chaining.
|
|
35
|
+
*/ withProfile(profile) {
|
|
15
36
|
this.nativeHandle.withProfile(profile);
|
|
16
37
|
return this;
|
|
17
38
|
}
|
|
18
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Stages the time between two delivered positions, in seconds. It has no effect until
|
|
41
|
+
* `restart()`. Positions arrive less often when the system has no new fix. `0` delivers every
|
|
42
|
+
* position the system produces.
|
|
43
|
+
*
|
|
44
|
+
* On Android, it replaces the update interval the profile requests from the provider. On iOS, the
|
|
45
|
+
* system decides the rate and positions that arrive sooner than the interval are dropped.
|
|
46
|
+
*
|
|
47
|
+
* @param intervalSeconds A finite number of seconds, `0` or greater. Throws for other values.
|
|
48
|
+
* @return The same handle, for chaining.
|
|
49
|
+
*/ withInterval(intervalSeconds) {
|
|
19
50
|
this.nativeHandle.withInterval(intervalSeconds);
|
|
20
51
|
return this;
|
|
21
52
|
}
|
|
22
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Subscribes again with the settings staged by `withProfile()` and `withInterval()`.
|
|
55
|
+
* It does not resume a paused watcher.
|
|
56
|
+
*
|
|
57
|
+
* @return `false` when the provider rejects the request right away. Later failures arrive through
|
|
58
|
+
* `onError`.
|
|
59
|
+
*/ restart() {
|
|
23
60
|
return this.nativeHandle.restart();
|
|
24
61
|
}
|
|
25
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Reads the current flags of the watcher.
|
|
64
|
+
*/ status() {
|
|
26
65
|
return this.nativeHandle.status();
|
|
27
66
|
}
|
|
28
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Removes all listeners and releases the native watcher.
|
|
69
|
+
*/ dispose() {
|
|
29
70
|
this.nativeHandle.removeAllListeners('positionChanged');
|
|
30
71
|
this.nativeHandle.release();
|
|
31
72
|
}
|
|
32
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Subscribes to the position and error events. One watcher can have multiple listeners.
|
|
75
|
+
*
|
|
76
|
+
* @param onPosition Called when a new position is delivered.
|
|
77
|
+
* @param onError Called when an error occurs.
|
|
78
|
+
* @return A subscription object with a `remove` method that stops listening for changes.
|
|
79
|
+
*/ addListener(onPosition, onError) {
|
|
33
80
|
return this.nativeHandle.addListener('positionChanged', ({ data, error })=>{
|
|
34
81
|
if (error != null) {
|
|
35
82
|
onError?.(error);
|
|
@@ -41,7 +88,27 @@ export class PositionWatchHandle {
|
|
|
41
88
|
});
|
|
42
89
|
}
|
|
43
90
|
}
|
|
44
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Starts watching the position and returns the handle that controls the watcher.
|
|
93
|
+
*
|
|
94
|
+
* See [Show live position on a screen](#show-live-position-on-a-screen).
|
|
95
|
+
*
|
|
96
|
+
* @param options The profile and the callbacks for positions and errors.
|
|
97
|
+
* @return The handle for controlling the watcher.
|
|
98
|
+
* @throws When the foreground permission is not granted, when location services are off (iOS), or
|
|
99
|
+
* when the selected provider cannot watch the position (Android).
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const watcher = Location.watchPosition({
|
|
103
|
+
* profile: LocationProfile.FITNESS,
|
|
104
|
+
* onPosition: (position) => console.log(position.coordinates),
|
|
105
|
+
* onError: (error) => console.warn(error.code, error.message),
|
|
106
|
+
* });
|
|
107
|
+
*
|
|
108
|
+
* // When the positions are no longer needed:
|
|
109
|
+
* watcher.dispose();
|
|
110
|
+
* ```
|
|
111
|
+
*/ export function watchPosition({ profile = LocationProfile.DEFAULT, onPosition, onError }) {
|
|
45
112
|
const handle = new PositionWatchHandle(profile);
|
|
46
113
|
handle.addListener(onPosition, onError);
|
|
47
114
|
return handle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/PositionWatchHandle.ts"],"sourcesContent":[null],"names":["NativeLocationModuleNext","LocationProfile","PositionWatchHandle","nativeHandle","profile","DEFAULT","watchPosition","pause","resume","withProfile","withInterval","intervalSeconds","restart","status","dispose","removeAllListeners","release","addListener","onPosition","onError","data","error","handle"],"mappings":"AAEA,SAASA,wBAAwB,QAAQ,YAAY;AAErD,SAASC,eAAe,QAAQ,WAAW;AAQ3C,OAAO,MAAMC;IACMC,aAA6C;IAE9D,YAAYC,UAA2BH,gBAAgBI,OAAO,CAAE;QAC9D,IAAI,CAACF,YAAY,GAAGH,yBAAyBM,aAAa,CAACF;IAC7D;
|
|
1
|
+
{"version":3,"sources":["next/js/PositionWatchHandle.ts"],"sourcesContent":[null],"names":["NativeLocationModuleNext","LocationProfile","PositionWatchHandle","nativeHandle","profile","DEFAULT","watchPosition","pause","resume","withProfile","withInterval","intervalSeconds","restart","status","dispose","removeAllListeners","release","addListener","onPosition","onError","data","error","handle"],"mappings":"AAEA,SAASA,wBAAwB,QAAQ,YAAY;AAErD,SAASC,eAAe,QAAQ,WAAW;AAQ3C;;;;CAIC,GACD,OAAO,MAAMC;IACMC,aAA6C;IAE9D;;;;;GAKC,GACD,YAAYC,UAA2BH,gBAAgBI,OAAO,CAAE;QAC9D,IAAI,CAACF,YAAY,GAAGH,yBAAyBM,aAAa,CAACF;IAC7D;IAEA;;GAEC,GACDG,QAAc;QACZ,IAAI,CAACJ,YAAY,CAACI,KAAK;IACzB;IAEA;;;;;;GAMC,GACDC,SAAkB;QAChB,OAAO,IAAI,CAACL,YAAY,CAACK,MAAM;IACjC;IAEA;;;;GAIC,GACDC,YAAYL,OAAwB,EAAQ;QAC1C,IAAI,CAACD,YAAY,CAACM,WAAW,CAACL;QAC9B,OAAO,IAAI;IACb;IAEA;;;;;;;;;;GAUC,GACDM,aAAaC,eAAuB,EAAQ;QAC1C,IAAI,CAACR,YAAY,CAACO,YAAY,CAACC;QAC/B,OAAO,IAAI;IACb;IAEA;;;;;;GAMC,GACDC,UAAmB;QACjB,OAAO,IAAI,CAACT,YAAY,CAACS,OAAO;IAClC;IAEA;;GAEC,GACDC,SAA8B;QAC5B,OAAO,IAAI,CAACV,YAAY,CAACU,MAAM;IACjC;IAEA;;GAEC,GACDC,UAAgB;QACd,IAAI,CAACX,YAAY,CAACY,kBAAkB,CAAC;QACrC,IAAI,CAACZ,YAAY,CAACa,OAAO;IAC3B;IAEA;;;;;;GAMC,GACDC,YACEC,UAAwC,EACxCC,OAA6C,EAC1B;QACnB,OAAO,IAAI,CAAChB,YAAY,CAACc,WAAW,CAAC,mBAAmB,CAAC,EAAEG,IAAI,EAAEC,KAAK,EAAE;YACtE,IAAIA,SAAS,MAAM;gBACjBF,UAAUE;gBACV;YACF;YACA,IAAID,QAAQ,MAAM;gBAChBF,WAAWE;YACb;QACF;IACF;AACF;AAEA;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASd,cAAc,EAC5BF,UAAUH,gBAAgBI,OAAO,EACjCa,UAAU,EACVC,OAAO,EACa;IACpB,MAAMG,SAAS,IAAIpB,oBAAoBE;IACvCkB,OAAOL,WAAW,CAACC,YAAYC;IAC/B,OAAOG;AACT"}
|
|
@@ -1,2 +1,27 @@
|
|
|
1
1
|
import type { GetPositionOptions, Position } from '../types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Resolves with a single fix. It returns a cached fix when one is younger than `maxCachedAge`.
|
|
4
|
+
* Otherwise, it waits up to `timeout` seconds for a new one and falls back to the last known
|
|
5
|
+
* location when none arrives. With `timeout` `0`, it returns the last known location right away.
|
|
6
|
+
* Check `timestamp` when freshness matters.
|
|
7
|
+
*
|
|
8
|
+
* @param getPositionOptions The options for the location request.
|
|
9
|
+
* @return A promise that resolves to the position, or `null` when the device has none.
|
|
10
|
+
* @throws When the foreground permission is not granted, or when location services are off (iOS).
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const position = await Location.getPosition({ maxCachedAge: 60, timeout: 10 });
|
|
14
|
+
* if (!position) {
|
|
15
|
+
* console.log('No location available');
|
|
16
|
+
* return;
|
|
17
|
+
* }
|
|
18
|
+
* const ageSeconds = (Date.now() - position.timestamp) / 1000;
|
|
19
|
+
* if (ageSeconds > 60) {
|
|
20
|
+
* console.log(
|
|
21
|
+
* `Last known location from ${Math.round(ageSeconds)} s ago, no fresh fix within the timeout`
|
|
22
|
+
* );
|
|
23
|
+
* }
|
|
24
|
+
* console.log(position.coordinates.latitude, position.coordinates.longitude);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function getPosition(getPositionOptions?: GetPositionOptions): Promise<Position | null>;
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { NativeLocationModuleNext } from '../native';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Resolves with a single fix. It returns a cached fix when one is younger than `maxCachedAge`.
|
|
4
|
+
* Otherwise, it waits up to `timeout` seconds for a new one and falls back to the last known
|
|
5
|
+
* location when none arrives. With `timeout` `0`, it returns the last known location right away.
|
|
6
|
+
* Check `timestamp` when freshness matters.
|
|
7
|
+
*
|
|
8
|
+
* @param getPositionOptions The options for the location request.
|
|
9
|
+
* @return A promise that resolves to the position, or `null` when the device has none.
|
|
10
|
+
* @throws When the foreground permission is not granted, or when location services are off (iOS).
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const position = await Location.getPosition({ maxCachedAge: 60, timeout: 10 });
|
|
14
|
+
* if (!position) {
|
|
15
|
+
* console.log('No location available');
|
|
16
|
+
* return;
|
|
17
|
+
* }
|
|
18
|
+
* const ageSeconds = (Date.now() - position.timestamp) / 1000;
|
|
19
|
+
* if (ageSeconds > 60) {
|
|
20
|
+
* console.log(
|
|
21
|
+
* `Last known location from ${Math.round(ageSeconds)} s ago, no fresh fix within the timeout`
|
|
22
|
+
* );
|
|
23
|
+
* }
|
|
24
|
+
* console.log(position.coordinates.latitude, position.coordinates.longitude);
|
|
25
|
+
* ```
|
|
26
|
+
*/ export async function getPosition(getPositionOptions) {
|
|
27
|
+
return NativeLocationModuleNext.getPosition(getPositionOptions);
|
|
4
28
|
}
|
|
5
29
|
|
|
6
30
|
//# sourceMappingURL=getPosition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/getPosition.ts"],"sourcesContent":[null],"names":["NativeLocationModuleNext","getPosition","
|
|
1
|
+
{"version":3,"sources":["next/js/getPosition.ts"],"sourcesContent":[null],"names":["NativeLocationModuleNext","getPosition","getPositionOptions"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,YAAY;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,eAAeC,YACpBC,kBAAuC;IAEvC,OAAOF,yBAAyBC,WAAW,CAACC;AAC9C"}
|
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether location services are turned on for the whole device. This is the system toggle,
|
|
3
|
+
* not the app's permission: with services off, no app receives a position even when its permission
|
|
4
|
+
* is granted.
|
|
5
|
+
* See [Handle location services turned off](#handle-location-services-turned-off).
|
|
6
|
+
*/
|
|
1
7
|
export declare function hasLocationServicesEnabled(): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Asks the user to turn location services on. With the GMS provider, this is an in-app dialog; with
|
|
10
|
+
* the Android provider, it opens the system Settings and resolves when the user returns. Resolves
|
|
11
|
+
* with `true` when services are already on.
|
|
12
|
+
* See [Handle location services turned off](#handle-location-services-turned-off).
|
|
13
|
+
*
|
|
14
|
+
* @return A promise that resolves to `true` when services are on after the user answered.
|
|
15
|
+
* @platform android
|
|
16
|
+
*/
|
|
2
17
|
export declare function enableLocationServices(): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Tracks whether location services are on, re-reading the switch every time the app returns to the
|
|
20
|
+
* foreground. `enable` calls `enableLocationServices`, so it works on Android only.
|
|
21
|
+
* See [Handle location services turned off](#handle-location-services-turned-off).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const [enabled, enable] = useLocationServices();
|
|
26
|
+
*
|
|
27
|
+
* if (!enabled) {
|
|
28
|
+
* return <Button title="Turn on location services" onPress={enable} />;
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
3
32
|
export declare function useLocationServices(): [enabled: boolean, enable: () => Promise<boolean>];
|
|
@@ -2,16 +2,42 @@ import { Platform, UnavailabilityError } from 'expo';
|
|
|
2
2
|
import { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { AppState } from 'react-native';
|
|
4
4
|
import { NativeLocationModuleNext } from '../native';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Checks whether location services are turned on for the whole device. This is the system toggle,
|
|
7
|
+
* not the app's permission: with services off, no app receives a position even when its permission
|
|
8
|
+
* is granted.
|
|
9
|
+
* See [Handle location services turned off](#handle-location-services-turned-off).
|
|
10
|
+
*/ export function hasLocationServicesEnabled() {
|
|
6
11
|
return NativeLocationModuleNext.hasLocationServicesEnabled();
|
|
7
12
|
}
|
|
8
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Asks the user to turn location services on. With the GMS provider, this is an in-app dialog; with
|
|
15
|
+
* the Android provider, it opens the system Settings and resolves when the user returns. Resolves
|
|
16
|
+
* with `true` when services are already on.
|
|
17
|
+
* See [Handle location services turned off](#handle-location-services-turned-off).
|
|
18
|
+
*
|
|
19
|
+
* @return A promise that resolves to `true` when services are on after the user answered.
|
|
20
|
+
* @platform android
|
|
21
|
+
*/ export async function enableLocationServices() {
|
|
9
22
|
if (Platform.OS !== 'android') {
|
|
10
23
|
throw new UnavailabilityError('expo-location', 'enableLocationServices');
|
|
11
24
|
}
|
|
12
25
|
return NativeLocationModuleNext.enableLocationServices();
|
|
13
26
|
}
|
|
14
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Tracks whether location services are on, re-reading the switch every time the app returns to the
|
|
29
|
+
* foreground. `enable` calls `enableLocationServices`, so it works on Android only.
|
|
30
|
+
* See [Handle location services turned off](#handle-location-services-turned-off).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const [enabled, enable] = useLocationServices();
|
|
35
|
+
*
|
|
36
|
+
* if (!enabled) {
|
|
37
|
+
* return <Button title="Turn on location services" onPress={enable} />;
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/ export function useLocationServices() {
|
|
15
41
|
const [enabled, setEnabled] = useState(hasLocationServicesEnabled);
|
|
16
42
|
useEffect(()=>{
|
|
17
43
|
const subscription = AppState.addEventListener('change', (state)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/locationServices.ts"],"sourcesContent":[null],"names":["Platform","UnavailabilityError","useCallback","useEffect","useState","AppState","NativeLocationModuleNext","hasLocationServicesEnabled","enableLocationServices","OS","useLocationServices","enabled","setEnabled","subscription","addEventListener","state","remove","enable","result"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,mBAAmB,QAAQ,OAAO;AACrD,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AACzD,SAASC,QAAQ,QAAQ,eAAe;AAExC,SAASC,wBAAwB,QAAQ,YAAY;AAErD,OAAO,SAASC;IACd,OAAOD,yBAAyBC,0BAA0B;AAC5D;AAEA,OAAO,eAAeC;IACpB,IAAIR,SAASS,EAAE,KAAK,WAAW;QAC7B,MAAM,IAAIR,oBAAoB,iBAAiB;IACjD;IAEA,OAAOK,yBAAyBE,sBAAsB;AACxD;AAEA,OAAO,SAASE;IACd,MAAM,CAACC,SAASC,WAAW,GAAGR,SAASG;IAEvCJ,UAAU;QACR,MAAMU,eAAeR,SAASS,gBAAgB,CAAC,UAAU,CAACC;YACxD,IAAIA,UAAU,UAAU;gBACtBH,WAAWL;YACb;QACF;QACA,OAAO,IAAMM,aAAaG,MAAM;IAClC,GAAG,EAAE;IAEL,MAAMC,SAASf,YAAY;QACzB,MAAMgB,SAAS,MAAMV;QACrBI,WAAWM;QACX,OAAOA;IACT,GAAG,EAAE;IAEL,OAAO;QAACP;QAASM;KAAO;AAC1B"}
|
|
1
|
+
{"version":3,"sources":["next/js/locationServices.ts"],"sourcesContent":[null],"names":["Platform","UnavailabilityError","useCallback","useEffect","useState","AppState","NativeLocationModuleNext","hasLocationServicesEnabled","enableLocationServices","OS","useLocationServices","enabled","setEnabled","subscription","addEventListener","state","remove","enable","result"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,mBAAmB,QAAQ,OAAO;AACrD,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AACzD,SAASC,QAAQ,QAAQ,eAAe;AAExC,SAASC,wBAAwB,QAAQ,YAAY;AAErD;;;;;CAKC,GACD,OAAO,SAASC;IACd,OAAOD,yBAAyBC,0BAA0B;AAC5D;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeC;IACpB,IAAIR,SAASS,EAAE,KAAK,WAAW;QAC7B,MAAM,IAAIR,oBAAoB,iBAAiB;IACjD;IAEA,OAAOK,yBAAyBE,sBAAsB;AACxD;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASE;IACd,MAAM,CAACC,SAASC,WAAW,GAAGR,SAASG;IAEvCJ,UAAU;QACR,MAAMU,eAAeR,SAASS,gBAAgB,CAAC,UAAU,CAACC;YACxD,IAAIA,UAAU,UAAU;gBACtBH,WAAWL;YACb;QACF;QACA,OAAO,IAAMM,aAAaG,MAAM;IAClC,GAAG,EAAE;IAEL,MAAMC,SAASf,YAAY;QACzB,MAAMgB,SAAS,MAAMV;QACrBI,WAAWM;QACX,OAAOA;IACT,GAAG,EAAE;IAEL,OAAO;QAACP;QAASM;KAAO;AAC1B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TaskManagerError } from 'expo-task-manager';
|
|
2
|
+
import type { Position } from './Position.types';
|
|
3
|
+
/**
|
|
4
|
+
* The parameters of `defineLocationTask`.
|
|
5
|
+
*/
|
|
6
|
+
export type LocationTaskOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the task. Must match the name passed to the `LocationUpdatesHandle` constructor;
|
|
9
|
+
* both default to the same name.
|
|
10
|
+
*/
|
|
11
|
+
taskName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Called with every position delivered to the task.
|
|
14
|
+
*/
|
|
15
|
+
onPosition: (position: Position) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Called when the task receives an error instead of a position.
|
|
18
|
+
*/
|
|
19
|
+
onError?: (error: TaskManagerError) => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["next/types/LocationTask.types.ts"],"sourcesContent":[null],"names":[],"mappings":"AAIA;;CAEC,GACD,WAcE"}
|