expo-location 58.0.14 → 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.
Files changed (84) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/location/taskConsumers/LocationTaskConsumer.kt +6 -0
  4. package/build/next/index.d.ts +1 -1
  5. package/build/next/index.js.map +1 -1
  6. package/build/next/js/LocationProvider.d.ts +35 -0
  7. package/build/next/js/LocationProvider.js +35 -6
  8. package/build/next/js/LocationProvider.js.map +1 -1
  9. package/build/next/js/LocationUpdatesHandle.d.ts +45 -7
  10. package/build/next/js/LocationUpdatesHandle.js +43 -7
  11. package/build/next/js/LocationUpdatesHandle.js.map +1 -1
  12. package/build/next/js/Permissions.d.ts +63 -0
  13. package/build/next/js/Permissions.js +63 -6
  14. package/build/next/js/Permissions.js.map +1 -1
  15. package/build/next/js/PositionWatchHandle.d.ts +78 -0
  16. package/build/next/js/PositionWatchHandle.js +78 -11
  17. package/build/next/js/PositionWatchHandle.js.map +1 -1
  18. package/build/next/js/getPosition.d.ts +26 -1
  19. package/build/next/js/getPosition.js +26 -2
  20. package/build/next/js/getPosition.js.map +1 -1
  21. package/build/next/js/locationServices.d.ts +29 -0
  22. package/build/next/js/locationServices.js +29 -3
  23. package/build/next/js/locationServices.js.map +1 -1
  24. package/build/next/types/LocationTask.types.d.ts +20 -0
  25. package/build/next/types/LocationTask.types.js +5 -0
  26. package/build/next/types/LocationTask.types.js.map +1 -0
  27. package/build/next/types/Permissions.types.d.ts +68 -0
  28. package/build/next/types/Permissions.types.js +51 -9
  29. package/build/next/types/Permissions.types.js.map +1 -1
  30. package/build/next/types/Position.types.d.ts +203 -2
  31. package/build/next/types/Position.types.js +51 -7
  32. package/build/next/types/Position.types.js.map +1 -1
  33. package/build/next/types/index.d.ts +1 -0
  34. package/build/next/types/index.js +1 -0
  35. package/build/next/types/index.js.map +1 -1
  36. package/ios/TaskConsumers/EXGeofencingTaskConsumer.m +16 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.14/expo.modules.location-58.0.14-sources.jar → 58.0.15/expo.modules.location-58.0.15-sources.jar} +0 -0
  38. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.md5 +1 -0
  39. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha1 +1 -0
  40. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha256 +1 -0
  41. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha512 +1 -0
  42. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.14/expo.modules.location-58.0.14.aar → 58.0.15/expo.modules.location-58.0.15.aar} +0 -0
  43. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.md5 +1 -0
  44. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha1 +1 -0
  45. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha256 +1 -0
  46. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha512 +1 -0
  47. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.14/expo.modules.location-58.0.14.module → 58.0.15/expo.modules.location-58.0.15.module} +22 -22
  48. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.md5 +1 -0
  49. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha1 +1 -0
  50. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha256 +1 -0
  51. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha512 +1 -0
  52. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.14/expo.modules.location-58.0.14.pom → 58.0.15/expo.modules.location-58.0.15.pom} +1 -1
  53. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.md5 +1 -0
  54. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha1 +1 -0
  55. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha256 +1 -0
  56. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha512 +1 -0
  57. package/package.json +2 -2
  58. package/src/next/index.ts +1 -0
  59. package/src/next/js/LocationProvider.ts +35 -0
  60. package/src/next/js/LocationUpdatesHandle.ts +45 -8
  61. package/src/next/js/Permissions.ts +63 -0
  62. package/src/next/js/PositionWatchHandle.ts +78 -0
  63. package/src/next/js/getPosition.ts +29 -2
  64. package/src/next/js/locationServices.ts +29 -0
  65. package/src/next/types/LocationTask.types.ts +22 -0
  66. package/src/next/types/Permissions.types.ts +68 -0
  67. package/src/next/types/Position.types.ts +203 -2
  68. package/src/next/types/index.ts +1 -0
  69. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14-sources.jar.md5 +0 -1
  70. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14-sources.jar.sha1 +0 -1
  71. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14-sources.jar.sha256 +0 -1
  72. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14-sources.jar.sha512 +0 -1
  73. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.aar.md5 +0 -1
  74. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.aar.sha1 +0 -1
  75. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.aar.sha256 +0 -1
  76. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.aar.sha512 +0 -1
  77. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.module.md5 +0 -1
  78. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.module.sha1 +0 -1
  79. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.module.sha256 +0 -1
  80. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.module.sha512 +0 -1
  81. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.pom.md5 +0 -1
  82. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.pom.sha1 +0 -1
  83. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.pom.sha256 +0 -1
  84. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - [Android] Stop the location foreground service when a background location task is unregistered while the service is still binding, so a `stopLocationUpdatesAsync` that follows `startLocationUpdatesAsync` within milliseconds no longer leaves the service and its notification running. ([#51236](https://github.com/expo/expo/pull/51236) by [@jrceranornelson](https://github.com/jrceranornelson))
8
+ - [iOS] Fix `notifyOnEnter` being ignored for geofencing regions. The native side read a misspelled key, so every region reported enter events regardless of the flag. ([#51444](https://github.com/expo/expo/pull/51444) by [@Wenszel](https://github.com/Wenszel))
9
+ - [iOS] Fix an infinite region restart loop when geofencing exceeds the maximum number of monitored regions. ([#51443](https://github.com/expo/expo/pull/51443) by [@Wenszel](https://github.com/Wenszel))
10
+ - Add TSDoc to the `expo-location/next` API. ([#51231](https://github.com/expo/expo/pull/51231) by [@Wenszel](https://github.com/Wenszel))
11
+
3
12
  ## 58.0.14
4
13
 
5
14
  ### Patch Changes
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '58.0.14'
7
+ version = '58.0.15'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.location"
11
11
  defaultConfig {
12
12
  versionCode 29
13
- versionName "58.0.14"
13
+ versionName "58.0.15"
14
14
  consumerProguardFiles("proguard-rules.pro")
15
15
  }
16
16
  }
@@ -222,6 +222,12 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
222
222
  mService?.let {
223
223
  it.setParentContext(context)
224
224
  it.startForeground(serviceOptions)
225
+ // The task was unregistered while this bind was pending: didUnregister() found no
226
+ // service to stop. Stop it now. startForeground() above is still required, since the
227
+ // service was started with startForegroundService().
228
+ if (mTask == null) {
229
+ stopForegroundService()
230
+ }
225
231
  }
226
232
  }
227
233
 
@@ -1,3 +1,3 @@
1
1
  export * as Location from './Location';
2
2
  export { useForegroundLocationPermissions, useBackgroundLocationPermissions, useLocationServices, PositionWatchHandle, LocationProvider, LocationUpdatesHandle, defineLocationTask, } from './js';
3
- export { LocationProfile, LocationAccuracy, LocationScope, RequestPermissionsAccuracyOption, type Coordinates, type Position, type PositionUpdate, type PositionWatchError, type PositionWatchStatus, type WatchPositionParams, type GetPositionOptions, type LocationPermissionResponse, type RequestPermissionsOptions, type LocationProviderRefType, } from './types';
3
+ export { LocationProfile, LocationAccuracy, LocationScope, RequestPermissionsAccuracyOption, type Coordinates, type Position, type PositionUpdate, type PositionWatchError, type PositionWatchStatus, type WatchPositionParams, type GetPositionOptions, type LocationTaskOptions, type LocationPermissionResponse, type RequestPermissionsOptions, type LocationProviderRefType, } from './types';
@@ -1 +1 @@
1
- {"version":3,"sources":["next/index.ts"],"sourcesContent":[null],"names":["Location","useForegroundLocationPermissions","useBackgroundLocationPermissions","useLocationServices","PositionWatchHandle","LocationProvider","LocationUpdatesHandle","defineLocationTask","LocationProfile","LocationAccuracy","LocationScope","RequestPermissionsAccuracyOption"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,aAAa;AAEvC,SACEC,gCAAgC,EAChCC,gCAAgC,EAChCC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,qBAAqB,EACrBC,kBAAkB,QACb,OAAO;AAEd,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,gCAAgC,QAW3B,UAAU"}
1
+ {"version":3,"sources":["next/index.ts"],"sourcesContent":[null],"names":["Location","useForegroundLocationPermissions","useBackgroundLocationPermissions","useLocationServices","PositionWatchHandle","LocationProvider","LocationUpdatesHandle","defineLocationTask","LocationProfile","LocationAccuracy","LocationScope","RequestPermissionsAccuracyOption"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,aAAa;AAEvC,SACEC,gCAAgC,EAChCC,gCAAgC,EAChCC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,qBAAqB,EACrBC,kBAAkB,QACb,OAAO;AAEd,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,gCAAgC,QAY3B,UAAU"}
@@ -1,9 +1,44 @@
1
1
  import type { SharedRef } from 'expo';
2
2
  import type { LocationProviderRefType } from '../types';
3
+ /**
4
+ * The backends that can serve positions on Android. The default tries Google Play services first
5
+ * and falls back to the Android framework, so most apps never need this. Pass the result to
6
+ * `setLocationProvider`.
7
+ *
8
+ * @platform android
9
+ */
3
10
  export declare class LocationProvider {
11
+ /**
12
+ * The fused location provider from Google Play services.
13
+ *
14
+ * @platform android
15
+ */
4
16
  static Gms(): SharedRef<LocationProviderRefType>;
17
+ /**
18
+ * The Android framework `LocationManager`, available without Google Play services.
19
+ *
20
+ * @platform android
21
+ */
5
22
  static Android(): SharedRef<LocationProviderRefType>;
23
+ /**
24
+ * Tries the providers in order and uses the first one that can serve the request.
25
+ *
26
+ * @param providers The providers to try, most preferred first.
27
+ * @platform android
28
+ */
6
29
  static Fallback(providers: SharedRef<LocationProviderRefType>[]): SharedRef<LocationProviderRefType>;
7
30
  }
31
+ /**
32
+ * Selects the provider that serves all later location requests.
33
+ *
34
+ * @param provider A provider from `LocationProvider`.
35
+ * @platform android
36
+ */
8
37
  export declare function setLocationProvider(provider: SharedRef<LocationProviderRefType>): void;
38
+ /**
39
+ * Gets the name of the provider currently serving positions: `GMS`, `Android`, or the chain of a
40
+ * fallback, such as the default `Fallback: GMS -> Android`.
41
+ *
42
+ * @platform android
43
+ */
9
44
  export declare function getSelectedLocationProviderName(): string;
@@ -1,19 +1,48 @@
1
1
  import { NativeLocationModuleNext, NativeLocationProvider } from '../native';
2
- export class LocationProvider {
3
- static Gms() {
2
+ /**
3
+ * The backends that can serve positions on Android. The default tries Google Play services first
4
+ * and falls back to the Android framework, so most apps never need this. Pass the result to
5
+ * `setLocationProvider`.
6
+ *
7
+ * @platform android
8
+ */ export class LocationProvider {
9
+ /**
10
+ * The fused location provider from Google Play services.
11
+ *
12
+ * @platform android
13
+ */ static Gms() {
4
14
  return NativeLocationProvider.Gms();
5
15
  }
6
- static Android() {
16
+ /**
17
+ * The Android framework `LocationManager`, available without Google Play services.
18
+ *
19
+ * @platform android
20
+ */ static Android() {
7
21
  return NativeLocationProvider.Android();
8
22
  }
9
- static Fallback(providers) {
23
+ /**
24
+ * Tries the providers in order and uses the first one that can serve the request.
25
+ *
26
+ * @param providers The providers to try, most preferred first.
27
+ * @platform android
28
+ */ static Fallback(providers) {
10
29
  return NativeLocationProvider.Fallback(providers);
11
30
  }
12
31
  }
13
- export function setLocationProvider(provider) {
32
+ /**
33
+ * Selects the provider that serves all later location requests.
34
+ *
35
+ * @param provider A provider from `LocationProvider`.
36
+ * @platform android
37
+ */ export function setLocationProvider(provider) {
14
38
  NativeLocationModuleNext.setLocationProvider(provider);
15
39
  }
16
- export function getSelectedLocationProviderName() {
40
+ /**
41
+ * Gets the name of the provider currently serving positions: `GMS`, `Android`, or the chain of a
42
+ * fallback, such as the default `Fallback: GMS -> Android`.
43
+ *
44
+ * @platform android
45
+ */ export function getSelectedLocationProviderName() {
17
46
  return NativeLocationModuleNext.getSelectedLocationProviderName();
18
47
  }
19
48
 
@@ -1 +1 @@
1
- {"version":3,"sources":["next/js/LocationProvider.ts"],"sourcesContent":[null],"names":["NativeLocationModuleNext","NativeLocationProvider","LocationProvider","Gms","Android","Fallback","providers","setLocationProvider","provider","getSelectedLocationProviderName"],"mappings":"AAEA,SAASA,wBAAwB,EAAEC,sBAAsB,QAAQ,YAAY;AAG7E,OAAO,MAAMC;IACX,OAAOC,MAA0C;QAC/C,OAAOF,uBAAuBE,GAAG;IACnC;IAEA,OAAOC,UAA8C;QACnD,OAAOH,uBAAuBG,OAAO;IACvC;IAEA,OAAOC,SACLC,SAA+C,EACX;QACpC,OAAOL,uBAAuBI,QAAQ,CAACC;IACzC;AACF;AAEA,OAAO,SAASC,oBAAoBC,QAA4C;IAC9ER,yBAAyBO,mBAAmB,CAACC;AAC/C;AAEA,OAAO,SAASC;IACd,OAAOT,yBAAyBS,+BAA+B;AACjE"}
1
+ {"version":3,"sources":["next/js/LocationProvider.ts"],"sourcesContent":[null],"names":["NativeLocationModuleNext","NativeLocationProvider","LocationProvider","Gms","Android","Fallback","providers","setLocationProvider","provider","getSelectedLocationProviderName"],"mappings":"AAEA,SAASA,wBAAwB,EAAEC,sBAAsB,QAAQ,YAAY;AAG7E;;;;;;CAMC,GACD,OAAO,MAAMC;IACX;;;;GAIC,GACD,OAAOC,MAA0C;QAC/C,OAAOF,uBAAuBE,GAAG;IACnC;IAEA;;;;GAIC,GACD,OAAOC,UAA8C;QACnD,OAAOH,uBAAuBG,OAAO;IACvC;IAEA;;;;;GAKC,GACD,OAAOC,SACLC,SAA+C,EACX;QACpC,OAAOL,uBAAuBI,QAAQ,CAACC;IACzC;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASC,oBAAoBC,QAA4C;IAC9ER,yBAAyBO,mBAAmB,CAACC;AAC/C;AAEA;;;;;CAKC,GACD,OAAO,SAASC;IACd,OAAOT,yBAAyBS,+BAA+B;AACjE"}
@@ -1,15 +1,53 @@
1
- import type { TaskManagerError } from 'expo-task-manager';
2
- import type { LocationProfile, Position } from '../types';
1
+ import type { LocationProfile, LocationTaskOptions } from '../types';
2
+ /**
3
+ * Starts and stops the delivery of positions to the task defined with `defineLocationTask`.
4
+ * The delivery is registered with the system, so it outlives the JS context: it survives the app
5
+ * moving to the background and, with the background permission, the app being terminated.
6
+ *
7
+ * On Android, positions keep arriving after the app process ended. Requires the background
8
+ * permission.
9
+ *
10
+ * On iOS, positions come from `CLLocationUpdate.liveUpdates`. Requires the `location` background
11
+ * mode and the foreground permission.
12
+ *
13
+ * See [Receive positions in the background](#receive-positions-in-the-background).
14
+ */
3
15
  export declare class LocationUpdatesHandle {
4
16
  private readonly nativeHandle;
17
+ /**
18
+ * @param taskName The task that receives the positions. Must match the name passed to
19
+ * `defineLocationTask`; both default to the same name.
20
+ */
5
21
  constructor(taskName?: string);
22
+ /**
23
+ * Stages the profile for the next `start()`. It has no effect on a delivery that is already
24
+ * running; call `stop()` and `start()` again to apply it.
25
+ *
26
+ * @return The same handle, for chaining.
27
+ */
6
28
  withProfile(profile: LocationProfile): this;
29
+ /**
30
+ * Registers the delivery with the system and starts sending positions to the task.
31
+ * @throws When location services are off or the required permission is missing: the background
32
+ * permission on Android, the foreground permission on iOS, where the `location` background mode
33
+ * is also required.
34
+ */
7
35
  start(): Promise<void>;
36
+ /**
37
+ * Unregisters the delivery. Positions stop arriving and the app is no longer relaunched for them.
38
+ */
8
39
  stop(): Promise<void>;
40
+ /**
41
+ * Checks whether the delivery is registered with the system. It stays registered across app
42
+ * restarts, so check it on launch before calling `start()` again.
43
+ */
9
44
  hasStarted(): Promise<boolean>;
10
45
  }
11
- export declare function defineLocationTask({ taskName, onPosition, onError, }: {
12
- taskName?: string;
13
- onPosition: (position: Position) => void;
14
- onError?: (error: TaskManagerError) => void;
15
- }): void;
46
+ /**
47
+ * Defines the task that receives the positions started with `LocationUpdatesHandle`.
48
+ * Wraps `TaskManager.defineTask`, so call it in the global scope of a module imported at startup.
49
+ * See [Receive positions in the background](#receive-positions-in-the-background).
50
+ *
51
+ * @param options The task name and the callbacks for positions and errors.
52
+ */
53
+ export declare function defineLocationTask({ taskName, onPosition, onError, }: LocationTaskOptions): void;
@@ -1,25 +1,61 @@
1
1
  import { NativeLocationUpdatesHandle } from '../native';
2
2
  const DEFAULT_LOCATION_TASK_NAME = 'expo-location-background-location';
3
- export class LocationUpdatesHandle {
3
+ /**
4
+ * Starts and stops the delivery of positions to the task defined with `defineLocationTask`.
5
+ * The delivery is registered with the system, so it outlives the JS context: it survives the app
6
+ * moving to the background and, with the background permission, the app being terminated.
7
+ *
8
+ * On Android, positions keep arriving after the app process ended. Requires the background
9
+ * permission.
10
+ *
11
+ * On iOS, positions come from `CLLocationUpdate.liveUpdates`. Requires the `location` background
12
+ * mode and the foreground permission.
13
+ *
14
+ * See [Receive positions in the background](#receive-positions-in-the-background).
15
+ */ export class LocationUpdatesHandle {
4
16
  nativeHandle;
5
- constructor(taskName = DEFAULT_LOCATION_TASK_NAME){
17
+ /**
18
+ * @param taskName The task that receives the positions. Must match the name passed to
19
+ * `defineLocationTask`; both default to the same name.
20
+ */ constructor(taskName = DEFAULT_LOCATION_TASK_NAME){
6
21
  this.nativeHandle = new NativeLocationUpdatesHandle(taskName);
7
22
  }
8
- withProfile(profile) {
23
+ /**
24
+ * Stages the profile for the next `start()`. It has no effect on a delivery that is already
25
+ * running; call `stop()` and `start()` again to apply it.
26
+ *
27
+ * @return The same handle, for chaining.
28
+ */ withProfile(profile) {
9
29
  this.nativeHandle.withProfile(profile);
10
30
  return this;
11
31
  }
12
- start() {
32
+ /**
33
+ * Registers the delivery with the system and starts sending positions to the task.
34
+ * @throws When location services are off or the required permission is missing: the background
35
+ * permission on Android, the foreground permission on iOS, where the `location` background mode
36
+ * is also required.
37
+ */ start() {
13
38
  return this.nativeHandle.start();
14
39
  }
15
- stop() {
40
+ /**
41
+ * Unregisters the delivery. Positions stop arriving and the app is no longer relaunched for them.
42
+ */ stop() {
16
43
  return this.nativeHandle.stop();
17
44
  }
18
- hasStarted() {
45
+ /**
46
+ * Checks whether the delivery is registered with the system. It stays registered across app
47
+ * restarts, so check it on launch before calling `start()` again.
48
+ */ hasStarted() {
19
49
  return this.nativeHandle.hasStarted();
20
50
  }
21
51
  }
22
- export function defineLocationTask({ taskName = DEFAULT_LOCATION_TASK_NAME, onPosition, onError }) {
52
+ /**
53
+ * Defines the task that receives the positions started with `LocationUpdatesHandle`.
54
+ * Wraps `TaskManager.defineTask`, so call it in the global scope of a module imported at startup.
55
+ * See [Receive positions in the background](#receive-positions-in-the-background).
56
+ *
57
+ * @param options The task name and the callbacks for positions and errors.
58
+ */ export function defineLocationTask({ taskName = DEFAULT_LOCATION_TASK_NAME, onPosition, onError }) {
23
59
  requireTaskManager().defineTask(taskName, async ({ data, error })=>{
24
60
  if (error) {
25
61
  onError?.(error);
@@ -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":"AAEA,SAASA,2BAA2B,QAAQ,YAAY;AAIxD,MAAMC,6BAA6B;AAEnC,OAAO,MAAMC;IACMC,aAA+C;IAEhE,YAAYC,WAAmBH,0BAA0B,CAAE;QACzD,IAAI,CAACE,YAAY,GAAG,IAAIH,4BAA4BI;IACtD;IAEAC,YAAYC,OAAwB,EAAQ;QAC1C,IAAI,CAACH,YAAY,CAACE,WAAW,CAACC;QAC9B,OAAO,IAAI;IACb;IAEAC,QAAuB;QACrB,OAAO,IAAI,CAACJ,YAAY,CAACI,KAAK;IAChC;IAEAC,OAAsB;QACpB,OAAO,IAAI,CAACL,YAAY,CAACK,IAAI;IAC/B;IAEAC,aAA+B;QAC7B,OAAO,IAAI,CAACN,YAAY,CAACM,UAAU;IACrC;AACF;AAEA,OAAO,SAASC,mBAAmB,EACjCN,WAAWH,0BAA0B,EACrCU,UAAU,EACVC,OAAO,EAKR;IACCC,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
+ {"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
- export async function getForegroundPermissions() {
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
- export async function requestForegroundPermissions(options) {
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
- export async function getBackgroundPermissions() {
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
- export async function requestBackgroundPermissions(options) {
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
- export const useForegroundLocationPermissions = createPermissionHook({
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
- export const useBackgroundLocationPermissions = createPermissionHook({
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;