expo-location 12.1.2 → 13.0.2

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 (58) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/android/build.gradle +4 -13
  3. package/android/src/main/java/expo/modules/location/LocationHelpers.java +2 -2
  4. package/android/src/main/java/expo/modules/location/LocationModule.java +13 -12
  5. package/android/src/main/java/expo/modules/location/LocationPackage.java +2 -2
  6. package/android/src/main/java/expo/modules/location/LocationRequestCallbacks.java +1 -1
  7. package/android/src/main/java/expo/modules/location/exceptions/LocationBackgroundUnauthorizedException.java +2 -2
  8. package/android/src/main/java/expo/modules/location/exceptions/LocationRequestRejectedException.java +2 -2
  9. package/android/src/main/java/expo/modules/location/exceptions/LocationSettingsUnsatisfiedException.java +2 -2
  10. package/android/src/main/java/expo/modules/location/exceptions/LocationUnauthorizedException.java +2 -2
  11. package/android/src/main/java/expo/modules/location/exceptions/LocationUnavailableException.java +2 -2
  12. package/android/src/main/java/expo/modules/location/taskConsumers/LocationTaskConsumer.java +7 -6
  13. package/build/ExpoLocation.d.ts +1 -1
  14. package/build/ExpoLocation.js +1 -1
  15. package/build/ExpoLocation.js.map +1 -1
  16. package/build/ExpoLocation.web.js +6 -5
  17. package/build/ExpoLocation.web.js.map +1 -1
  18. package/build/GeolocationPolyfill.js +2 -2
  19. package/build/GeolocationPolyfill.js.map +1 -1
  20. package/build/Location.d.ts +22 -2
  21. package/build/Location.js +30 -3
  22. package/build/Location.js.map +1 -1
  23. package/build/LocationEventEmitter.d.ts +1 -1
  24. package/build/LocationEventEmitter.js +1 -1
  25. package/build/LocationEventEmitter.js.map +1 -1
  26. package/build/LocationEventEmitter.web.d.ts +1 -1
  27. package/build/LocationEventEmitter.web.js +1 -1
  28. package/build/LocationEventEmitter.web.js.map +1 -1
  29. package/build/LocationGoogleGeocoding.js +2 -2
  30. package/build/LocationGoogleGeocoding.js.map +1 -1
  31. package/build/LocationSubscribers.js +4 -2
  32. package/build/LocationSubscribers.js.map +1 -1
  33. package/ios/EXLocation/EXLocation.h +4 -4
  34. package/ios/EXLocation/EXLocation.m +83 -83
  35. package/ios/EXLocation/Requesters/EXBaseLocationRequester.h +2 -2
  36. package/ios/EXLocation/Requesters/EXBaseLocationRequester.m +7 -12
  37. package/ios/EXLocation/Requesters/EXForegroundPermissionRequester.m +1 -1
  38. package/ios/EXLocation/TaskConsumers/EXGeofencingTaskConsumer.m +4 -4
  39. package/ios/EXLocation/TaskConsumers/EXLocationTaskConsumer.m +5 -7
  40. package/ios/EXLocation.podspec +2 -2
  41. package/ios/EXLocation.xcframework/Info.plist +5 -5
  42. package/ios/EXLocation.xcframework/ios-arm64/EXLocation.framework/EXLocation +0 -0
  43. package/ios/EXLocation.xcframework/ios-arm64/EXLocation.framework/Info.plist +0 -0
  44. package/ios/EXLocation.xcframework/ios-arm64_x86_64-simulator/EXLocation.framework/EXLocation +0 -0
  45. package/ios/EXLocation.xcframework/ios-arm64_x86_64-simulator/EXLocation.framework/Info.plist +0 -0
  46. package/package.json +5 -5
  47. package/plugin/build/withLocation.d.ts +1 -0
  48. package/plugin/build/withLocation.js +30 -17
  49. package/plugin/src/withLocation.ts +40 -15
  50. package/src/ExpoLocation.ts +1 -1
  51. package/src/ExpoLocation.web.ts +5 -5
  52. package/src/GeolocationPolyfill.ts +2 -2
  53. package/src/Location.ts +40 -4
  54. package/src/LocationEventEmitter.ts +1 -1
  55. package/src/LocationEventEmitter.web.ts +1 -1
  56. package/src/LocationGoogleGeocoding.ts +2 -2
  57. package/src/LocationSubscribers.ts +1 -1
  58. package/android/src/main/java/expo/modules/location/utils/TimeoutObject.java +0 -55
package/CHANGELOG.md CHANGED
@@ -10,14 +10,35 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 12.1.2 — 2021-06-24
13
+ ## 13.0.2 — 2021-10-15
14
14
 
15
15
  _This version does not introduce any user-facing changes._
16
16
 
17
- ## 12.1.1 — 2021-06-22
17
+ ## 13.0.1 — 2021-10-01
18
18
 
19
19
  _This version does not introduce any user-facing changes._
20
20
 
21
+ ## 13.0.0 — 2021-09-28
22
+
23
+ ### 🛠 Breaking changes
24
+
25
+ - Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach))
26
+
27
+ ### 🎉 New features
28
+
29
+ - [plugin] Added `isIosBackgroundLocationEnabled` to enable the background location UIMode ([#14142](https://github.com/expo/expo/pull/14142) by [@EvanBacon](https://github.com/EvanBacon))
30
+ - Use stable manifest ID where applicable. ([#12964](https://github.com/expo/expo/pull/12964) by [@wschurman](https://github.com/wschurman))
31
+ - Add useForegroundPermissions and useBackgroundPermissions hooks from modules factory. ([#13860](https://github.com/expo/expo/pull/13860) by [@bycedric](https://github.com/bycedric))
32
+
33
+ ### 🐛 Bug fixes
34
+
35
+ - Fixed `Location.getCurrentPositionAsync` throwing `Location provider is unavailable.` error. ([#14281](https://github.com/expo/expo/pull/14281) by [@m1st4ke](https://github.com/m1st4ke))
36
+ - Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo))
37
+
38
+ ### 💡 Others
39
+
40
+ - Updated `@expo/config-plugins` ([#14443](https://github.com/expo/expo/pull/14443) by [@EvanBacon](https://github.com/EvanBacon))
41
+
21
42
  ## 12.1.0 — 2021-06-16
22
43
 
23
44
  ### 🐛 Bug fixes
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '12.1.2'
6
+ version = '13.0.2'
7
7
 
8
8
  buildscript {
9
9
  // Simple helper that allows the root project to override versions declared by this library.
@@ -57,25 +57,16 @@ android {
57
57
  minSdkVersion safeExtGet("minSdkVersion", 21)
58
58
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
59
59
  versionCode 29
60
- versionName "12.1.2"
60
+ versionName "13.0.2"
61
61
  }
62
62
  lintOptions {
63
63
  abortOnError false
64
64
  }
65
65
  }
66
66
 
67
- if (new File(rootProject.projectDir.parentFile, 'package.json').exists()) {
68
- apply from: project(":unimodules-core").file("../unimodules-core.gradle")
69
- } else {
70
- throw new GradleException(
71
- "'unimodules-core.gradle' was not found in the usual React Native dependency location. " +
72
- "This package can only be used in such projects. Are you sure you've installed the dependencies properly?")
73
- }
74
-
75
67
  dependencies {
76
- unimodule "unimodules-core"
77
- unimodule 'expo-modules-core'
78
- unimodule "unimodules-task-manager-interface"
68
+ implementation project(':expo-modules-core')
69
+ implementation project(':unimodules-task-manager-interface')
79
70
 
80
71
  api 'com.google.android.gms:play-services-location:16.0.0'
81
72
 
@@ -14,8 +14,8 @@ import com.google.android.gms.location.LocationRequest;
14
14
 
15
15
  import java.util.Map;
16
16
 
17
- import org.unimodules.core.Promise;
18
- import org.unimodules.core.errors.CodedException;
17
+ import expo.modules.core.Promise;
18
+ import expo.modules.core.errors.CodedException;
19
19
  import io.nlopez.smartlocation.location.config.LocationAccuracy;
20
20
  import io.nlopez.smartlocation.location.config.LocationParams;
21
21
 
@@ -41,15 +41,15 @@ import java.util.List;
41
41
  import java.util.Map;
42
42
  import java.util.Objects;
43
43
 
44
- import org.unimodules.core.ExportedModule;
45
- import org.unimodules.core.ModuleRegistry;
46
- import org.unimodules.core.Promise;
47
- import org.unimodules.core.interfaces.ActivityEventListener;
48
- import org.unimodules.core.interfaces.ActivityProvider;
49
- import org.unimodules.core.interfaces.ExpoMethod;
50
- import org.unimodules.core.interfaces.LifecycleEventListener;
51
- import org.unimodules.core.interfaces.services.EventEmitter;
52
- import org.unimodules.core.interfaces.services.UIManager;
44
+ import expo.modules.core.ExportedModule;
45
+ import expo.modules.core.ModuleRegistry;
46
+ import expo.modules.core.Promise;
47
+ import expo.modules.core.interfaces.ActivityEventListener;
48
+ import expo.modules.core.interfaces.ActivityProvider;
49
+ import expo.modules.core.interfaces.ExpoMethod;
50
+ import expo.modules.core.interfaces.LifecycleEventListener;
51
+ import expo.modules.core.interfaces.services.EventEmitter;
52
+ import expo.modules.core.interfaces.services.UIManager;
53
53
  import org.unimodules.interfaces.taskManager.TaskManagerInterface;
54
54
 
55
55
  import androidx.annotation.RequiresApi;
@@ -548,20 +548,21 @@ public class LocationModule extends ExportedModule implements LifecycleEventList
548
548
  final FusedLocationProviderClient locationProvider = getLocationProvider();
549
549
 
550
550
  LocationCallback locationCallback = new LocationCallback() {
551
+ boolean isLocationAvailable = false;
551
552
  @Override
552
553
  public void onLocationResult(LocationResult locationResult) {
553
554
  Location location = locationResult != null ? locationResult.getLastLocation() : null;
554
555
 
555
556
  if (location != null) {
556
557
  callbacks.onLocationChanged(location);
558
+ } else if (!isLocationAvailable) {
559
+ callbacks.onLocationError(new LocationUnavailableException());
557
560
  }
558
561
  }
559
562
 
560
563
  @Override
561
564
  public void onLocationAvailability(LocationAvailability locationAvailability) {
562
- if (!locationAvailability.isLocationAvailable()) {
563
- callbacks.onLocationError(new LocationUnavailableException());
564
- }
565
+ isLocationAvailable = locationAvailability.isLocationAvailable();
565
566
  }
566
567
  };
567
568
 
@@ -5,8 +5,8 @@ import android.content.Context;
5
5
  import java.util.Collections;
6
6
  import java.util.List;
7
7
 
8
- import org.unimodules.core.ExportedModule;
9
- import org.unimodules.core.BasePackage;
8
+ import expo.modules.core.ExportedModule;
9
+ import expo.modules.core.BasePackage;
10
10
 
11
11
  public class LocationPackage extends BasePackage {
12
12
  @Override
@@ -2,7 +2,7 @@ package expo.modules.location;
2
2
 
3
3
  import android.location.Location;
4
4
 
5
- import org.unimodules.core.errors.CodedException;
5
+ import expo.modules.core.errors.CodedException;
6
6
 
7
7
  abstract class LocationRequestCallbacks {
8
8
  public void onLocationChanged(Location location) {}
@@ -1,7 +1,7 @@
1
1
  package expo.modules.location.exceptions;
2
2
 
3
- import org.unimodules.core.interfaces.CodedThrowable;
4
- import org.unimodules.core.errors.CodedException;
3
+ import expo.modules.core.interfaces.CodedThrowable;
4
+ import expo.modules.core.errors.CodedException;
5
5
 
6
6
  public class LocationBackgroundUnauthorizedException extends CodedException implements CodedThrowable {
7
7
  public LocationBackgroundUnauthorizedException() {
@@ -1,7 +1,7 @@
1
1
  package expo.modules.location.exceptions;
2
2
 
3
- import org.unimodules.core.interfaces.CodedThrowable;
4
- import org.unimodules.core.errors.CodedException;
3
+ import expo.modules.core.interfaces.CodedThrowable;
4
+ import expo.modules.core.errors.CodedException;
5
5
 
6
6
  public class LocationRequestRejectedException extends CodedException implements CodedThrowable {
7
7
  public LocationRequestRejectedException(Exception cause) {
@@ -1,7 +1,7 @@
1
1
  package expo.modules.location.exceptions;
2
2
 
3
- import org.unimodules.core.interfaces.CodedThrowable;
4
- import org.unimodules.core.errors.CodedException;
3
+ import expo.modules.core.interfaces.CodedThrowable;
4
+ import expo.modules.core.errors.CodedException;
5
5
 
6
6
  public class LocationSettingsUnsatisfiedException extends CodedException implements CodedThrowable {
7
7
  public LocationSettingsUnsatisfiedException() {
@@ -1,7 +1,7 @@
1
1
  package expo.modules.location.exceptions;
2
2
 
3
- import org.unimodules.core.interfaces.CodedThrowable;
4
- import org.unimodules.core.errors.CodedException;
3
+ import expo.modules.core.interfaces.CodedThrowable;
4
+ import expo.modules.core.errors.CodedException;
5
5
 
6
6
  public class LocationUnauthorizedException extends CodedException implements CodedThrowable {
7
7
  public LocationUnauthorizedException() {
@@ -1,7 +1,7 @@
1
1
  package expo.modules.location.exceptions;
2
2
 
3
- import org.unimodules.core.interfaces.CodedThrowable;
4
- import org.unimodules.core.errors.CodedException;
3
+ import expo.modules.core.interfaces.CodedThrowable;
4
+ import expo.modules.core.errors.CodedException;
5
5
 
6
6
  public class LocationUnavailableException extends CodedException implements CodedThrowable {
7
7
  public LocationUnavailableException() {
@@ -21,11 +21,11 @@ import com.google.android.gms.location.LocationServices;
21
21
  import com.google.android.gms.tasks.OnCompleteListener;
22
22
  import com.google.android.gms.tasks.Task;
23
23
 
24
- import org.unimodules.core.MapHelper;
25
- import org.unimodules.core.arguments.MapArguments;
26
- import org.unimodules.core.arguments.ReadableArguments;
27
- import org.unimodules.core.interfaces.Arguments;
28
- import org.unimodules.core.interfaces.LifecycleEventListener;
24
+ import expo.modules.core.MapHelper;
25
+ import expo.modules.core.arguments.MapArguments;
26
+ import expo.modules.core.arguments.ReadableArguments;
27
+ import expo.modules.core.interfaces.Arguments;
28
+ import expo.modules.core.interfaces.LifecycleEventListener;
29
29
  import org.unimodules.interfaces.taskManager.TaskConsumer;
30
30
  import org.unimodules.interfaces.taskManager.TaskConsumerInterface;
31
31
  import org.unimodules.interfaces.taskManager.TaskExecutionCallback;
@@ -227,7 +227,8 @@ public class LocationTaskConsumer extends TaskConsumer implements TaskConsumerIn
227
227
  Bundle extras = new Bundle();
228
228
  final Bundle serviceOptions = options.getArguments(FOREGROUND_SERVICE_KEY).toBundle();
229
229
 
230
- extras.putString("appId", mTask.getAppId());
230
+ // extras param name is appId for legacy reasons
231
+ extras.putString("appId", mTask.getAppScopeKey());
231
232
  extras.putString("taskName", mTask.getName());
232
233
  serviceIntent.putExtras(extras);
233
234
 
@@ -1,2 +1,2 @@
1
- declare const _default: import("@unimodules/core").ProxyNativeModule;
1
+ declare const _default: import("expo-modules-core").ProxyNativeModule;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- import { NativeModulesProxy } from '@unimodules/core';
1
+ import { NativeModulesProxy } from 'expo-modules-core';
2
2
  export default NativeModulesProxy.ExpoLocation;
3
3
  //# sourceMappingURL=ExpoLocation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoLocation.js","sourceRoot":"","sources":["../src/ExpoLocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,eAAe,kBAAkB,CAAC,YAAY,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\nexport default NativeModulesProxy.ExpoLocation;\n"]}
1
+ {"version":3,"file":"ExpoLocation.js","sourceRoot":"","sources":["../src/ExpoLocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,eAAe,kBAAkB,CAAC,YAAY,CAAC","sourcesContent":["import { NativeModulesProxy } from 'expo-modules-core';\nexport default NativeModulesProxy.ExpoLocation;\n"]}
@@ -2,6 +2,7 @@ import { PermissionStatus } from 'expo-modules-core';
2
2
  import { LocationAccuracy, } from './Location.types';
3
3
  import { LocationEventEmitter } from './LocationEventEmitter';
4
4
  class GeocoderError extends Error {
5
+ code;
5
6
  constructor() {
6
7
  super('Geocoder service is not available for this device.');
7
8
  this.code = 'E_NO_GEOCODER';
@@ -39,8 +40,8 @@ function isLocationValid(location, options) {
39
40
  * for the current location, but there is no better way on web so far :(
40
41
  */
41
42
  async function getPermissionsAsync() {
42
- return new Promise(resolve => {
43
- const resolveWithStatus = status => resolve({
43
+ return new Promise((resolve) => {
44
+ const resolveWithStatus = (status) => resolve({
44
45
  status,
45
46
  granted: status === PermissionStatus.GRANTED,
46
47
  canAskAgain: true,
@@ -74,7 +75,7 @@ export default {
74
75
  },
75
76
  async getCurrentPositionAsync(options) {
76
77
  return new Promise((resolve, reject) => {
77
- const resolver = position => {
78
+ const resolver = (position) => {
78
79
  lastKnownPosition = geolocationPositionToJSON(position);
79
80
  resolve(lastKnownPosition);
80
81
  };
@@ -101,9 +102,9 @@ export default {
101
102
  throw new GeocoderError();
102
103
  },
103
104
  async watchPositionImplAsync(watchId, options) {
104
- return new Promise(resolve => {
105
+ return new Promise((resolve) => {
105
106
  // @ts-ignore: the types here need to be fixed
106
- watchId = global.navigator.geolocation.watchPosition(position => {
107
+ watchId = global.navigator.geolocation.watchPosition((position) => {
107
108
  lastKnownPosition = geolocationPositionToJSON(position);
108
109
  LocationEventEmitter.emit('Expo.locationChanged', {
109
110
  watchId,
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoLocation.web.js","sourceRoot":"","sources":["../src/ExpoLocation.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,E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;YACnD,OAAO,CACR,CAAC;YACF,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,mBAAmB;IACnB,KAAK,CAAC,uBAAuB;QAC3B,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,iCAAiC;QACrC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,iCAAiC;QACrC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,6BAA6B;QACjC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IACD,KAAK,CAAC,6BAA6B;QACjC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IAED,QAAQ;IACR,cAAc,KAAI,CAAC;IACnB,aAAa,KAAI,CAAC;CACnB,CAAC","sourcesContent":["import { PermissionResponse, PermissionStatus } from 'expo-modules-core';\n\nimport {\n LocationLastKnownOptions,\n LocationObject,\n LocationOptions,\n LocationAccuracy,\n} from './Location.types';\nimport { LocationEventEmitter } from './LocationEventEmitter';\n\nclass GeocoderError extends Error {\n code: string;\n\n constructor() {\n super('Geocoder service is not available for this device.');\n this.code = 'E_NO_GEOCODER';\n }\n}\n\n/**\n * Converts `GeolocationPosition` to JavaScript object.\n */\nfunction geolocationPositionToJSON(position: LocationObject): LocationObject {\n const { coords, timestamp } = position;\n return {\n coords: {\n latitude: coords.latitude,\n longitude: coords.longitude,\n altitude: coords.altitude,\n accuracy: coords.accuracy,\n altitudeAccuracy: coords.altitudeAccuracy,\n heading: coords.heading,\n speed: coords.speed,\n },\n timestamp,\n };\n}\n\n/**\n * Checks whether given location didn't exceed given `maxAge` and fits in the required accuracy.\n */\nfunction isLocationValid(location: LocationObject, options: LocationLastKnownOptions): boolean {\n const maxAge = typeof options.maxAge === 'number' ? options.maxAge : Infinity;\n const requiredAccuracy =\n typeof options.requiredAccuracy === 'number' ? options.requiredAccuracy : Infinity;\n const locationAccuracy = location.coords.accuracy ?? Infinity;\n\n return Date.now() - location.timestamp <= maxAge && locationAccuracy <= requiredAccuracy;\n}\n\n/**\n * Gets the permission details. The implementation is not very good as it actually requests\n * for the current location, but there is no better way on web so far :(\n */\nasync function getPermissionsAsync(): Promise<PermissionResponse> {\n return new Promise<PermissionResponse>(resolve => {\n const resolveWithStatus = status =>\n resolve({\n status,\n granted: status === PermissionStatus.GRANTED,\n canAskAgain: true,\n expires: 0,\n });\n\n navigator.geolocation.getCurrentPosition(\n () => resolveWithStatus(PermissionStatus.GRANTED),\n ({ code }) => {\n if (code === 1 /* PERMISSION_DENIED */) {\n resolveWithStatus(PermissionStatus.DENIED);\n } else {\n resolveWithStatus(PermissionStatus.UNDETERMINED);\n }\n },\n { enableHighAccuracy: false, maximumAge: Infinity }\n );\n });\n}\n\nlet lastKnownPosition: LocationObject | null = null;\n\nexport default {\n get name(): string {\n return 'ExpoLocation';\n },\n async getProviderStatusAsync(): Promise<{ locationServicesEnabled: boolean }> {\n return {\n locationServicesEnabled: 'geolocation' in navigator,\n };\n },\n async getLastKnownPositionAsync(\n options: LocationLastKnownOptions = {}\n ): Promise<LocationObject | null> {\n if (lastKnownPosition && isLocationValid(lastKnownPosition, options)) {\n return lastKnownPosition;\n }\n return null;\n },\n async getCurrentPositionAsync(options: LocationOptions): Promise<LocationObject> {\n return new Promise<LocationObject>((resolve, reject) => {\n const resolver = position => {\n lastKnownPosition = geolocationPositionToJSON(position);\n resolve(lastKnownPosition);\n };\n navigator.geolocation.getCurrentPosition(resolver, reject, {\n maximumAge: Infinity,\n enableHighAccuracy: (options.accuracy ?? 0) > LocationAccuracy.Balanced,\n ...options,\n });\n });\n },\n async removeWatchAsync(watchId): Promise<void> {\n navigator.geolocation.clearWatch(watchId);\n },\n async watchDeviceHeading(headingId): Promise<void> {\n console.warn('Location.watchDeviceHeading: is not supported on web');\n },\n async hasServicesEnabledAsync(): Promise<boolean> {\n return 'geolocation' in navigator;\n },\n async geocodeAsync(): Promise<any[]> {\n throw new GeocoderError();\n },\n async reverseGeocodeAsync(): Promise<any[]> {\n throw new GeocoderError();\n },\n async watchPositionImplAsync(watchId: string, options: LocationOptions): Promise<string> {\n return new Promise<string>(resolve => {\n // @ts-ignore: the types here need to be fixed\n watchId = global.navigator.geolocation.watchPosition(\n position => {\n lastKnownPosition = geolocationPositionToJSON(position);\n LocationEventEmitter.emit('Expo.locationChanged', {\n watchId,\n location: lastKnownPosition,\n });\n },\n undefined,\n // @ts-ignore: the options object needs to be fixed\n options\n );\n resolve(watchId);\n });\n },\n\n getPermissionsAsync,\n async requestPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async requestForegroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async requestBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async getForegroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async getBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n\n // no-op\n startObserving() {},\n stopObserving() {},\n};\n"]}
1
+ {"version":3,"file":"ExpoLocation.web.js","sourceRoot":"","sources":["../src/ExpoLocation.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAIL,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,aAAc,SAAQ,KAAK;IAC/B,IAAI,CAAS;IAEb;QACE,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED;;GAEG;AACH,SAAS,yBAAyB,CAAC,QAAwB;IACzD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IACvC,OAAO;QACL,MAAM,EAAE;YACN,QAAQ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CAAC;IACD,KAAK,CAAC,6BAA6B;QACjC,OAAO,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IAED,QAAQ;IACR,cAAc,KAAI,CAAC;IACnB,aAAa,KAAI,CAAC;CACnB,CAAC","sourcesContent":["import { PermissionResponse, PermissionStatus } from 'expo-modules-core';\n\nimport {\n LocationLastKnownOptions,\n LocationObject,\n LocationOptions,\n LocationAccuracy,\n} from './Location.types';\nimport { LocationEventEmitter } from './LocationEventEmitter';\n\nclass GeocoderError extends Error {\n code: string;\n\n constructor() {\n super('Geocoder service is not available for this device.');\n this.code = 'E_NO_GEOCODER';\n }\n}\n\n/**\n * Converts `GeolocationPosition` to JavaScript object.\n */\nfunction geolocationPositionToJSON(position: LocationObject): LocationObject {\n const { coords, timestamp } = position;\n return {\n coords: {\n latitude: coords.latitude,\n longitude: coords.longitude,\n altitude: coords.altitude,\n accuracy: coords.accuracy,\n altitudeAccuracy: coords.altitudeAccuracy,\n heading: coords.heading,\n speed: coords.speed,\n },\n timestamp,\n };\n}\n\n/**\n * Checks whether given location didn't exceed given `maxAge` and fits in the required accuracy.\n */\nfunction isLocationValid(location: LocationObject, options: LocationLastKnownOptions): boolean {\n const maxAge = typeof options.maxAge === 'number' ? options.maxAge : Infinity;\n const requiredAccuracy =\n typeof options.requiredAccuracy === 'number' ? options.requiredAccuracy : Infinity;\n const locationAccuracy = location.coords.accuracy ?? Infinity;\n\n return Date.now() - location.timestamp <= maxAge && locationAccuracy <= requiredAccuracy;\n}\n\n/**\n * Gets the permission details. The implementation is not very good as it actually requests\n * for the current location, but there is no better way on web so far :(\n */\nasync function getPermissionsAsync(): Promise<PermissionResponse> {\n return new Promise<PermissionResponse>((resolve) => {\n const resolveWithStatus = (status) =>\n resolve({\n status,\n granted: status === PermissionStatus.GRANTED,\n canAskAgain: true,\n expires: 0,\n });\n\n navigator.geolocation.getCurrentPosition(\n () => resolveWithStatus(PermissionStatus.GRANTED),\n ({ code }) => {\n if (code === 1 /* PERMISSION_DENIED */) {\n resolveWithStatus(PermissionStatus.DENIED);\n } else {\n resolveWithStatus(PermissionStatus.UNDETERMINED);\n }\n },\n { enableHighAccuracy: false, maximumAge: Infinity }\n );\n });\n}\n\nlet lastKnownPosition: LocationObject | null = null;\n\nexport default {\n get name(): string {\n return 'ExpoLocation';\n },\n async getProviderStatusAsync(): Promise<{ locationServicesEnabled: boolean }> {\n return {\n locationServicesEnabled: 'geolocation' in navigator,\n };\n },\n async getLastKnownPositionAsync(\n options: LocationLastKnownOptions = {}\n ): Promise<LocationObject | null> {\n if (lastKnownPosition && isLocationValid(lastKnownPosition, options)) {\n return lastKnownPosition;\n }\n return null;\n },\n async getCurrentPositionAsync(options: LocationOptions): Promise<LocationObject> {\n return new Promise<LocationObject>((resolve, reject) => {\n const resolver = (position) => {\n lastKnownPosition = geolocationPositionToJSON(position);\n resolve(lastKnownPosition);\n };\n navigator.geolocation.getCurrentPosition(resolver, reject, {\n maximumAge: Infinity,\n enableHighAccuracy: (options.accuracy ?? 0) > LocationAccuracy.Balanced,\n ...options,\n });\n });\n },\n async removeWatchAsync(watchId): Promise<void> {\n navigator.geolocation.clearWatch(watchId);\n },\n async watchDeviceHeading(headingId): Promise<void> {\n console.warn('Location.watchDeviceHeading: is not supported on web');\n },\n async hasServicesEnabledAsync(): Promise<boolean> {\n return 'geolocation' in navigator;\n },\n async geocodeAsync(): Promise<any[]> {\n throw new GeocoderError();\n },\n async reverseGeocodeAsync(): Promise<any[]> {\n throw new GeocoderError();\n },\n async watchPositionImplAsync(watchId: string, options: LocationOptions): Promise<string> {\n return new Promise<string>((resolve) => {\n // @ts-ignore: the types here need to be fixed\n watchId = global.navigator.geolocation.watchPosition(\n (position) => {\n lastKnownPosition = geolocationPositionToJSON(position);\n LocationEventEmitter.emit('Expo.locationChanged', {\n watchId,\n location: lastKnownPosition,\n });\n },\n undefined,\n // @ts-ignore: the options object needs to be fixed\n options\n );\n resolve(watchId);\n });\n },\n\n getPermissionsAsync,\n async requestPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async requestForegroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async requestBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async getForegroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n async getBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return getPermissionsAsync();\n },\n\n // no-op\n startObserving() {},\n stopObserving() {},\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { Platform } from '@unimodules/core';
1
+ import { Platform } from 'expo-modules-core';
2
2
  import ExpoLocation from './ExpoLocation';
3
3
  import { LocationAccuracy } from './Location.types';
4
4
  import { LocationSubscriber } from './LocationSubscribers';
@@ -40,7 +40,7 @@ async function _getCurrentPositionAsyncWrapper(success, error, options) {
40
40
  // Polyfill: navigator.geolocation.watchPosition
41
41
  function watchPosition(success, error, options) {
42
42
  const watchId = LocationSubscriber.registerCallback(success);
43
- ExpoLocation.watchPositionImplAsync(watchId, options).catch(err => {
43
+ ExpoLocation.watchPositionImplAsync(watchId, options).catch((err) => {
44
44
  LocationSubscriber.unregisterCallback(watchId);
45
45
  error({ watchId, message: err.message, code: err.code });
46
46
  });
@@ -1 +1 @@
1
- {"version":3,"file":"GeolocationPolyfill.js","sourceRoot":"","sources":["../src/GeolocationPolyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAkB,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS3D,MAAM,UAAU,6BAA6B;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,gGAAgG;QAChG,cAAc;QACd,aAAa;QACb,MAAM,CAAC,SAAS,CAAC,WAAW,GAAG;YAC7B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AG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6CAA6C;AAC7C,SAAS,UAAU,CAAC,OAAe;IACjC,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { Platform } from '@unimodules/core';\n\nimport ExpoLocation from './ExpoLocation';\nimport { LocationObject, LocationAccuracy, LocationOptions } from './Location.types';\nimport { LocationSubscriber } from './LocationSubscribers';\n\ntype GeolocationSuccessCallback = (data: LocationObject) => void;\ntype GeolocationErrorCallback = (error: any) => void;\n\ntype GeolocationOptions = {\n enableHighAccuracy?: boolean;\n};\n\nexport function installWebGeolocationPolyfill(): void {\n if (Platform.OS !== 'web') {\n // Polyfill navigator.geolocation for interop with the core react-native and web API approach to\n // geolocation\n // @ts-ignore\n window.navigator.geolocation = {\n getCurrentPosition,\n watchPosition,\n clearWatch,\n\n // We don't polyfill stopObserving, this is an internal method that probably should not even exist\n // in react-native docs\n stopObserving: () => {},\n };\n }\n}\n\nfunction convertGeolocationOptions(options: GeolocationOptions): LocationOptions {\n return {\n accuracy: options.enableHighAccuracy ? LocationAccuracy.High : LocationAccuracy.Balanced,\n };\n}\n\nfunction getCurrentPosition(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback = () => {},\n options: GeolocationOptions = {}\n): void {\n _getCurrentPositionAsyncWrapper(success, error, options);\n}\n\n// This function exists to let us continue to return undefined from getCurrentPosition, while still\n// using async/await for the internal implementation of it\nasync function _getCurrentPositionAsyncWrapper(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback,\n options: GeolocationOptions\n): Promise<any> {\n try {\n await ExpoLocation.requestPermissionsAsync();\n const result = await ExpoLocation.getCurrentPositionAsync(convertGeolocationOptions(options));\n success(result);\n } catch (e) {\n error(e);\n }\n}\n\n// Polyfill: navigator.geolocation.watchPosition\nfunction watchPosition(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback,\n options: GeolocationOptions\n) {\n const watchId = LocationSubscriber.registerCallback(success);\n\n ExpoLocation.watchPositionImplAsync(watchId, options).catch(err => {\n LocationSubscriber.unregisterCallback(watchId);\n error({ watchId, message: err.message, code: err.code });\n });\n\n return watchId;\n}\n\n// Polyfill: navigator.geolocation.clearWatch\nfunction clearWatch(watchId: number) {\n LocationSubscriber.unregisterCallback(watchId);\n}\n"]}
1
+ {"version":3,"file":"GeolocationPolyfill.js","sourceRoot":"","sources":["../src/GeolocationPolyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAkB,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAS3D,MAAM,UAAU,6BAA6B;IAC3C,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,gGAAgG;QAChG,cAAc;QACd,aAAa;QACb,MAAM,CAAC,SAAS,CAAC,WAAW,GAAG;YAC7B,kBAAkB;YAClB,aAAa;YACb,UAAU;YAEV,kGAAkG;YAClG,uBAAuB;YACvB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;SACxB,CAAC;KACH;AACH,CAAC;AAED,SAAS,yBAAyB,CAAC,OAA2B;IAC5D,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAQ;KACzF,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,OAAmC,EACnC,QAAkC,GAAG,EAAE,GAAE,CAAC,EAC1C,UAA8B,EAAE;IAEhC,+BAA+B,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,mGAAmG;AACnG,0DAA0D;AAC1D,KAAK,UAAU,+BAA+B,CAC5C,OAAmC,EACnC,KAA+B,EAC/B,OAA2B;IAE3B,IAAI;QACF,MAAM,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,uBAAuB,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9F,OAAO,CAAC,MAAM,CAAC,CAAC;KACjB;IAAC,OAAO,CAAC,EAAE;QACV,KAAK,CAAC,CAAC,CAAC,CAAC;KACV;AACH,CAAC;AAED,gDAAgD;AAChD,SAAS,aAAa,CACpB,OAAmC,EACnC,KAA+B,EAC/B,OAA2B;IAE3B,MAAM,OAAO,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE7D,YAAY,CAAC,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QAClE,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,6CAA6C;AAC7C,SAAS,UAAU,CAAC,OAAe;IACjC,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { Platform } from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\nimport { LocationObject, LocationAccuracy, LocationOptions } from './Location.types';\nimport { LocationSubscriber } from './LocationSubscribers';\n\ntype GeolocationSuccessCallback = (data: LocationObject) => void;\ntype GeolocationErrorCallback = (error: any) => void;\n\ntype GeolocationOptions = {\n enableHighAccuracy?: boolean;\n};\n\nexport function installWebGeolocationPolyfill(): void {\n if (Platform.OS !== 'web') {\n // Polyfill navigator.geolocation for interop with the core react-native and web API approach to\n // geolocation\n // @ts-ignore\n window.navigator.geolocation = {\n getCurrentPosition,\n watchPosition,\n clearWatch,\n\n // We don't polyfill stopObserving, this is an internal method that probably should not even exist\n // in react-native docs\n stopObserving: () => {},\n };\n }\n}\n\nfunction convertGeolocationOptions(options: GeolocationOptions): LocationOptions {\n return {\n accuracy: options.enableHighAccuracy ? LocationAccuracy.High : LocationAccuracy.Balanced,\n };\n}\n\nfunction getCurrentPosition(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback = () => {},\n options: GeolocationOptions = {}\n): void {\n _getCurrentPositionAsyncWrapper(success, error, options);\n}\n\n// This function exists to let us continue to return undefined from getCurrentPosition, while still\n// using async/await for the internal implementation of it\nasync function _getCurrentPositionAsyncWrapper(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback,\n options: GeolocationOptions\n): Promise<any> {\n try {\n await ExpoLocation.requestPermissionsAsync();\n const result = await ExpoLocation.getCurrentPositionAsync(convertGeolocationOptions(options));\n success(result);\n } catch (e) {\n error(e);\n }\n}\n\n// Polyfill: navigator.geolocation.watchPosition\nfunction watchPosition(\n success: GeolocationSuccessCallback,\n error: GeolocationErrorCallback,\n options: GeolocationOptions\n) {\n const watchId = LocationSubscriber.registerCallback(success);\n\n ExpoLocation.watchPositionImplAsync(watchId, options).catch((err) => {\n LocationSubscriber.unregisterCallback(watchId);\n error({ watchId, message: err.message, code: err.code });\n });\n\n return watchId;\n}\n\n// Polyfill: navigator.geolocation.clearWatch\nfunction clearWatch(watchId: number) {\n LocationSubscriber.unregisterCallback(watchId);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { PermissionStatus, PermissionResponse } from 'expo-modules-core';
1
+ import { PermissionStatus, PermissionResponse, PermissionHookOptions } from 'expo-modules-core';
2
2
  import { LocationAccuracy, LocationCallback, LocationGeocodedAddress, LocationGeocodedLocation, LocationHeadingCallback, LocationHeadingObject, LocationLastKnownOptions, LocationObject, LocationOptions, LocationPermissionResponse, LocationProviderStatus, LocationRegion, LocationSubscription, LocationTaskOptions, LocationActivityType, LocationGeofencingEventType, LocationGeofencingRegionState, LocationGeocodingOptions } from './Location.types';
3
3
  import { LocationEventEmitter } from './LocationEventEmitter';
4
4
  import { setGoogleApiKey } from './LocationGoogleGeocoding';
@@ -61,6 +61,16 @@ export declare function getForegroundPermissionsAsync(): Promise<LocationPermiss
61
61
  * Requests the user to grant foreground location permissions.
62
62
  */
63
63
  export declare function requestForegroundPermissionsAsync(): Promise<LocationPermissionResponse>;
64
+ /**
65
+ * Check or request permissions for the foreground location.
66
+ * This uses both `requestForegroundPermissionsAsync` and `getForegroundPermissionsAsync` to interact with the permissions.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * const [status, requestPermission] = Location.useForegroundPermissions();
71
+ * ```
72
+ */
73
+ export declare const useForegroundPermissions: (options?: PermissionHookOptions<object> | undefined) => [LocationPermissionResponse | null, () => Promise<LocationPermissionResponse>, () => Promise<LocationPermissionResponse>];
64
74
  /**
65
75
  * Gets the current state of background location permissions.
66
76
  */
@@ -69,6 +79,16 @@ export declare function getBackgroundPermissionsAsync(): Promise<PermissionRespo
69
79
  * Requests the user to grant background location permissions.
70
80
  */
71
81
  export declare function requestBackgroundPermissionsAsync(): Promise<PermissionResponse>;
82
+ /**
83
+ * Check or request permissions for the foreground location.
84
+ * This uses both `requestBackgroundPermissionsAsync` and `getBackgroundPermissionsAsync` to interact with the permissions.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * const [status, requestPermission] = Location.useBackgroundPermissions();
89
+ * ```
90
+ */
91
+ export declare const useBackgroundPermissions: (options?: PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>];
72
92
  /**
73
93
  * Returns `true` if the device has location services enabled or `false` otherwise.
74
94
  */
@@ -86,6 +106,6 @@ export declare function hasStartedGeofencingAsync(taskName: string): Promise<boo
86
106
  */
87
107
  export declare function setApiKey(apiKey: string): void;
88
108
  export { LocationEventEmitter as EventEmitter, _getCurrentWatchId };
89
- export { LocationAccuracy as Accuracy, LocationActivityType as ActivityType, LocationGeofencingEventType as GeofencingEventType, LocationGeofencingRegionState as GeofencingRegionState, PermissionStatus, setGoogleApiKey, };
109
+ export { LocationAccuracy as Accuracy, LocationActivityType as ActivityType, LocationGeofencingEventType as GeofencingEventType, LocationGeofencingRegionState as GeofencingRegionState, PermissionStatus, PermissionHookOptions, setGoogleApiKey, };
90
110
  export { installWebGeolocationPolyfill } from './GeolocationPolyfill';
91
111
  export * from './Location.types';
package/build/Location.js CHANGED
@@ -1,5 +1,4 @@
1
- import { Platform } from '@unimodules/core';
2
- import { PermissionStatus } from 'expo-modules-core';
1
+ import { PermissionStatus, createPermissionHook, Platform, } from 'expo-modules-core';
3
2
  import ExpoLocation from './ExpoLocation';
4
3
  import { LocationAccuracy, LocationActivityType, LocationGeofencingEventType, LocationGeofencingRegionState, } from './Location.types';
5
4
  import { LocationEventEmitter } from './LocationEventEmitter';
@@ -54,7 +53,7 @@ export async function watchPositionAsync(options, callback) {
54
53
  export async function getHeadingAsync() {
55
54
  return new Promise(async (resolve) => {
56
55
  let tries = 0;
57
- const subscription = await watchHeadingAsync(heading => {
56
+ const subscription = await watchHeadingAsync((heading) => {
58
57
  if (heading.accuracy > 1 || tries > 5) {
59
58
  subscription.remove();
60
59
  resolve(heading);
@@ -130,6 +129,20 @@ export async function getForegroundPermissionsAsync() {
130
129
  export async function requestForegroundPermissionsAsync() {
131
130
  return await ExpoLocation.requestForegroundPermissionsAsync();
132
131
  }
132
+ // @needsAudit
133
+ /**
134
+ * Check or request permissions for the foreground location.
135
+ * This uses both `requestForegroundPermissionsAsync` and `getForegroundPermissionsAsync` to interact with the permissions.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const [status, requestPermission] = Location.useForegroundPermissions();
140
+ * ```
141
+ */
142
+ export const useForegroundPermissions = createPermissionHook({
143
+ getMethod: getForegroundPermissionsAsync,
144
+ requestMethod: requestForegroundPermissionsAsync,
145
+ });
133
146
  /**
134
147
  * Gets the current state of background location permissions.
135
148
  */
@@ -142,6 +155,20 @@ export async function getBackgroundPermissionsAsync() {
142
155
  export async function requestBackgroundPermissionsAsync() {
143
156
  return await ExpoLocation.requestBackgroundPermissionsAsync();
144
157
  }
158
+ // @needsAudit
159
+ /**
160
+ * Check or request permissions for the foreground location.
161
+ * This uses both `requestBackgroundPermissionsAsync` and `getBackgroundPermissionsAsync` to interact with the permissions.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * const [status, requestPermission] = Location.useBackgroundPermissions();
166
+ * ```
167
+ */
168
+ export const useBackgroundPermissions = createPermissionHook({
169
+ getMethod: getBackgroundPermissionsAsync,
170
+ requestMethod: requestBackgroundPermissionsAsync,
171
+ });
145
172
  // --- Location service
146
173
  /**
147
174
  * Returns `true` if the device has location services enabled or `false` otherwise.
@@ -1 +1 @@
1
- {"version":3,"file":"Location.js","sourceRoot":"","sources":["../src/Location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAsB,MAAM,mBAAmB,CAAC;AAEzE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAchB,oBAAoB,EACpB,2BAA2B,EAC3B,6BAA6B,GAE9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAElG,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,OAAO,YAAY,CAAC,sBAAsB,EAAE,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,kFAAkF;IAClF,qGAAq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CAAC,CAAC;IAC1B,MAAM,YAAY,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,MAAM,YAAY,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,QAAgB;IAC9D,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,OAAO,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;IAC3F,eAAe,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAED,wBAAwB;AACxB,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEpE,8BAA8B;AAC9B,OAAO,EACL,gBAAgB,IAAI,QAAQ,EAC5B,oBAAoB,IAAI,YAAY,EACpC,2BAA2B,IAAI,mBAAmB,EAClD,6BAA6B,IAAI,qBAAqB,EACtD,gBAAgB,EAChB,eAAe,GAChB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,cAAc,kBAAkB,CAAC","sourcesContent":["import { Platform } from '@unimodules/core';\nimport { PermissionStatus, PermissionResponse } from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\nimport {\n LocationAccuracy,\n LocationCallback,\n LocationGeocodedAddress,\n LocationGeocodedLocation,\n LocationHeadingCallback,\n LocationHeadingObject,\n LocationLastKnownOptions,\n LocationObject,\n LocationOptions,\n LocationPermissionResponse,\n LocationProviderStatus,\n LocationRegion,\n LocationSubscription,\n LocationTaskOptions,\n LocationActivityType,\n LocationGeofencingEventType,\n LocationGeofencingRegionState,\n LocationGeocodingOptions,\n} from './Location.types';\nimport { LocationEventEmitter } from './LocationEventEmitter';\nimport {\n setGoogleApiKey,\n googleGeocodeAsync,\n googleReverseGeocodeAsync,\n} from './LocationGoogleGeocoding';\nimport { LocationSubscriber, HeadingSubscriber, _getCurrentWatchId } from './LocationSubscribers';\n\nexport async function getProviderStatusAsync(): Promise<LocationProviderStatus> {\n return ExpoLocation.getProviderStatusAsync();\n}\n\nexport async function enableNetworkProviderAsync(): Promise<void> {\n // If network provider is disabled (user's location mode is set to \"Device only\"),\n // Android's location provider may not give you any results. Use this method in order to ask the user\n // to change the location mode to \"High accuracy\" which uses Google Play services and enables network provider.\n // `getCurrentPositionAsync` and `watchPositionAsync` are doing it automatically anyway.\n\n if (Platform.OS === 'android') {\n return ExpoLocation.enableNetworkProviderAsync();\n }\n}\n\n/**\n * Requests for one-time delivery of the user's current location.\n * Depending on given `accuracy` option it may take some time to resolve,\n * especially when you're inside a building.\n */\nexport async function getCurrentPositionAsync(\n options: LocationOptions = {}\n): Promise<LocationObject> {\n return ExpoLocation.getCurrentPositionAsync(options);\n}\n\n/**\n * Gets the last known position of the device or `null` if it's not available\n * or doesn't match given requirements such as maximum age or required accuracy.\n * It's considered to be faster than `getCurrentPositionAsync` as it doesn't request for the current location.\n */\nexport async function getLastKnownPositionAsync(\n options: LocationLastKnownOptions = {}\n): Promise<LocationObject | null> {\n return ExpoLocation.getLastKnownPositionAsync(options);\n}\n\n/**\n * Starts watching for location changes.\n * Given callback will be called once the new location is available.\n */\nexport async function watchPositionAsync(options: LocationOptions, callback: LocationCallback) {\n const watchId = LocationSubscriber.registerCallback(callback);\n await ExpoLocation.watchPositionImplAsync(watchId, options);\n\n return {\n remove() {\n LocationSubscriber.unregisterCallback(watchId);\n },\n };\n}\n\n/**\n * Resolves to an object with current heading details.\n * To simplify, it calls `watchHeadingAsync` and waits for a couple of updates\n * and returns the one that is accurate enough.\n */\nexport async function getHeadingAsync(): Promise<LocationHeadingObject> {\n return new Promise<LocationHeadingObject>(async resolve => {\n let tries = 0;\n\n const subscription = await watchHeadingAsync(heading => {\n if (heading.accuracy > 1 || tries > 5) {\n subscription.remove();\n resolve(heading);\n } else {\n tries += 1;\n }\n });\n });\n}\n\n/**\n * Starts watching for heading changes.\n * Given callback will be called once the new heading is available.\n */\nexport async function watchHeadingAsync(\n callback: LocationHeadingCallback\n): Promise<LocationSubscription> {\n const watchId = HeadingSubscriber.registerCallback(callback);\n await ExpoLocation.watchDeviceHeading(watchId);\n\n return {\n remove() {\n HeadingSubscriber.unregisterCallback(watchId);\n },\n };\n}\n\n/**\n * Geocodes given address to an array of latitude-longitude coordinates.\n */\nexport async function geocodeAsync(\n address: string,\n options?: LocationGeocodingOptions\n): Promise<LocationGeocodedLocation[]> {\n if (typeof address !== 'string') {\n throw new TypeError(`Address to geocode must be a string. Got ${address} instead.`);\n }\n if (options?.useGoogleMaps || Platform.OS === 'web') {\n return await googleGeocodeAsync(address);\n }\n return await ExpoLocation.geocodeAsync(address);\n}\n\n/**\n * The opposite behavior of `geocodeAsync` — translates location coordinates to an array of addresses.\n */\nexport async function reverseGeocodeAsync(\n location: Pick<LocationGeocodedLocation, 'latitude' | 'longitude'>,\n options?: LocationGeocodingOptions\n): Promise<LocationGeocodedAddress[]> {\n if (typeof location.latitude !== 'number' || typeof location.longitude !== 'number') {\n throw new TypeError(\n 'Location to reverse-geocode must be an object with number properties `latitude` and `longitude`.'\n );\n }\n if (options?.useGoogleMaps || Platform.OS === 'web') {\n return await googleReverseGeocodeAsync(location);\n }\n return await ExpoLocation.reverseGeocodeAsync(location);\n}\n\n/**\n * Gets the current state of location permissions.\n * @deprecated Use `getForegroundPermissionsAsync()` or `getBackgroundPermissionsAsync()` instead.\n */\nexport async function getPermissionsAsync(): Promise<LocationPermissionResponse> {\n console.warn(\n `\"getPermissionsAsync()\" is now deprecated. Please use \"getForegroundPermissionsAsync()\" or \"getBackgroundPermissionsAsync()\" instead.`\n );\n return await ExpoLocation.getPermissionsAsync();\n}\n\n/**\n * Requests the user to grant location permissions.\n * @deprecated Use `requestForegroundPermissionsAsync()` or `requestBackgroundPermissionsAsync()` instead.\n */\nexport async function requestPermissionsAsync(): Promise<LocationPermissionResponse> {\n console.warn(\n `\"requestPermissionsAsync()\" is now deprecated. Please use \"requestForegroundPermissionsAsync()\" or \"requestBackgroundPermissionsAsync()\" instead.`\n );\n\n return await ExpoLocation.requestPermissionsAsync();\n}\n\n/**\n * Gets the current state of foreground location permissions.\n */\nexport async function getForegroundPermissionsAsync(): Promise<LocationPermissionResponse> {\n return await ExpoLocation.getForegroundPermissionsAsync();\n}\n\n/**\n * Requests the user to grant foreground location permissions.\n */\nexport async function requestForegroundPermissionsAsync(): Promise<LocationPermissionResponse> {\n return await ExpoLocation.requestForegroundPermissionsAsync();\n}\n\n/**\n * Gets the current state of background location permissions.\n */\nexport async function getBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return await ExpoLocation.getBackgroundPermissionsAsync();\n}\n\n/**\n * Requests the user to grant background location permissions.\n */\nexport async function requestBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return await ExpoLocation.requestBackgroundPermissionsAsync();\n}\n\n// --- Location service\n\n/**\n * Returns `true` if the device has location services enabled or `false` otherwise.\n */\nexport async function hasServicesEnabledAsync(): Promise<boolean> {\n return await ExpoLocation.hasServicesEnabledAsync();\n}\n\n// --- Background location updates\n\nfunction _validateTaskName(taskName: string) {\n if (!taskName || typeof taskName !== 'string') {\n throw new Error(`\\`taskName\\` must be a non-empty string. Got ${taskName} instead.`);\n }\n}\n\nexport async function isBackgroundLocationAvailableAsync(): Promise<boolean> {\n const providerStatus = await getProviderStatusAsync();\n return providerStatus.backgroundModeEnabled;\n}\n\nexport async function startLocationUpdatesAsync(\n taskName: string,\n options: LocationTaskOptions = { accuracy: LocationAccuracy.Balanced }\n): Promise<void> {\n _validateTaskName(taskName);\n await ExpoLocation.startLocationUpdatesAsync(taskName, options);\n}\n\nexport async function stopLocationUpdatesAsync(taskName: string): Promise<void> {\n _validateTaskName(taskName);\n await ExpoLocation.stopLocationUpdatesAsync(taskName);\n}\n\nexport async function hasStartedLocationUpdatesAsync(taskName: string): Promise<boolean> {\n _validateTaskName(taskName);\n return ExpoLocation.hasStartedLocationUpdatesAsync(taskName);\n}\n\n// --- Geofencing\n\nfunction _validateRegions(regions: LocationRegion[]) {\n if (!regions || regions.length === 0) {\n throw new Error(\n 'Regions array cannot be empty. Use `stopGeofencingAsync` if you want to stop geofencing all regions'\n );\n }\n for (const region of regions) {\n if (typeof region.latitude !== 'number') {\n throw new TypeError(`Region's latitude must be a number. Got '${region.latitude}' instead.`);\n }\n if (typeof region.longitude !== 'number') {\n throw new TypeError(\n `Region's longitude must be a number. Got '${region.longitude}' instead.`\n );\n }\n if (typeof region.radius !== 'number') {\n throw new TypeError(`Region's radius must be a number. Got '${region.radius}' instead.`);\n }\n }\n}\n\nexport async function startGeofencingAsync(\n taskName: string,\n regions: LocationRegion[] = []\n): Promise<void> {\n _validateTaskName(taskName);\n _validateRegions(regions);\n await ExpoLocation.startGeofencingAsync(taskName, { regions });\n}\n\nexport async function stopGeofencingAsync(taskName: string): Promise<void> {\n _validateTaskName(taskName);\n await ExpoLocation.stopGeofencingAsync(taskName);\n}\n\nexport async function hasStartedGeofencingAsync(taskName: string): Promise<boolean> {\n _validateTaskName(taskName);\n return ExpoLocation.hasStartedGeofencingAsync(taskName);\n}\n\n/**\n * @deprecated\n * Deprecated as of SDK39 in favour of `setGoogleApiKey`.\n */\nexport function setApiKey(apiKey: string): void {\n console.warn(\"Location's method `setApiKey` is deprecated in favor of `setGoogleApiKey`.\");\n setGoogleApiKey(apiKey);\n}\n\n// For internal purposes\nexport { LocationEventEmitter as EventEmitter, _getCurrentWatchId };\n\n// Export as namespaced types.\nexport {\n LocationAccuracy as Accuracy,\n LocationActivityType as ActivityType,\n LocationGeofencingEventType as GeofencingEventType,\n LocationGeofencingRegionState as GeofencingRegionState,\n PermissionStatus,\n setGoogleApiKey,\n};\n\nexport { installWebGeolocationPolyfill } from './GeolocationPolyfill';\nexport * from './Location.types';\n"]}
1
+ {"version":3,"file":"Location.js","sourceRoot":"","sources":["../src/Location.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGhB,oBAAoB,EACpB,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAchB,oBAAoB,EACpB,2BAA2B,EAC3B,6BAA6B,GAE9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAElG,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,OAAO,YAAY,CAAC,sBAAsB,EAAE,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,kFAAkF;IAClF,qGAAqG;IACrG,+GAA+G;IAC/G,wFAAwF;IAExF,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QAC7B,OAAO,YAAY,CAAC,0BAA0B,EAAE,CAAC;KAClD;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,UAA2B,EAAE;IAE7B,OAAO,YAAY,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,UAAoC,EAAE;IAEtC,OAAO,YAAY,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA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,CAAC,QAAQ,CAAC,CAAC;IAC5B,MAAM,YAAY,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,QAAgB;IAC9D,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,OAAO,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;IAC3F,eAAe,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAED,wBAAwB;AACxB,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEpE,8BAA8B;AAC9B,OAAO,EACL,gBAAgB,IAAI,QAAQ,EAC5B,oBAAoB,IAAI,YAAY,EACpC,2BAA2B,IAAI,mBAAmB,EAClD,6BAA6B,IAAI,qBAAqB,EACtD,gBAAgB,EAEhB,eAAe,GAChB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,cAAc,kBAAkB,CAAC","sourcesContent":["import {\n PermissionStatus,\n PermissionResponse,\n PermissionHookOptions,\n createPermissionHook,\n Platform,\n} from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\nimport {\n LocationAccuracy,\n LocationCallback,\n LocationGeocodedAddress,\n LocationGeocodedLocation,\n LocationHeadingCallback,\n LocationHeadingObject,\n LocationLastKnownOptions,\n LocationObject,\n LocationOptions,\n LocationPermissionResponse,\n LocationProviderStatus,\n LocationRegion,\n LocationSubscription,\n LocationTaskOptions,\n LocationActivityType,\n LocationGeofencingEventType,\n LocationGeofencingRegionState,\n LocationGeocodingOptions,\n} from './Location.types';\nimport { LocationEventEmitter } from './LocationEventEmitter';\nimport {\n setGoogleApiKey,\n googleGeocodeAsync,\n googleReverseGeocodeAsync,\n} from './LocationGoogleGeocoding';\nimport { LocationSubscriber, HeadingSubscriber, _getCurrentWatchId } from './LocationSubscribers';\n\nexport async function getProviderStatusAsync(): Promise<LocationProviderStatus> {\n return ExpoLocation.getProviderStatusAsync();\n}\n\nexport async function enableNetworkProviderAsync(): Promise<void> {\n // If network provider is disabled (user's location mode is set to \"Device only\"),\n // Android's location provider may not give you any results. Use this method in order to ask the user\n // to change the location mode to \"High accuracy\" which uses Google Play services and enables network provider.\n // `getCurrentPositionAsync` and `watchPositionAsync` are doing it automatically anyway.\n\n if (Platform.OS === 'android') {\n return ExpoLocation.enableNetworkProviderAsync();\n }\n}\n\n/**\n * Requests for one-time delivery of the user's current location.\n * Depending on given `accuracy` option it may take some time to resolve,\n * especially when you're inside a building.\n */\nexport async function getCurrentPositionAsync(\n options: LocationOptions = {}\n): Promise<LocationObject> {\n return ExpoLocation.getCurrentPositionAsync(options);\n}\n\n/**\n * Gets the last known position of the device or `null` if it's not available\n * or doesn't match given requirements such as maximum age or required accuracy.\n * It's considered to be faster than `getCurrentPositionAsync` as it doesn't request for the current location.\n */\nexport async function getLastKnownPositionAsync(\n options: LocationLastKnownOptions = {}\n): Promise<LocationObject | null> {\n return ExpoLocation.getLastKnownPositionAsync(options);\n}\n\n/**\n * Starts watching for location changes.\n * Given callback will be called once the new location is available.\n */\nexport async function watchPositionAsync(options: LocationOptions, callback: LocationCallback) {\n const watchId = LocationSubscriber.registerCallback(callback);\n await ExpoLocation.watchPositionImplAsync(watchId, options);\n\n return {\n remove() {\n LocationSubscriber.unregisterCallback(watchId);\n },\n };\n}\n\n/**\n * Resolves to an object with current heading details.\n * To simplify, it calls `watchHeadingAsync` and waits for a couple of updates\n * and returns the one that is accurate enough.\n */\nexport async function getHeadingAsync(): Promise<LocationHeadingObject> {\n return new Promise<LocationHeadingObject>(async (resolve) => {\n let tries = 0;\n\n const subscription = await watchHeadingAsync((heading) => {\n if (heading.accuracy > 1 || tries > 5) {\n subscription.remove();\n resolve(heading);\n } else {\n tries += 1;\n }\n });\n });\n}\n\n/**\n * Starts watching for heading changes.\n * Given callback will be called once the new heading is available.\n */\nexport async function watchHeadingAsync(\n callback: LocationHeadingCallback\n): Promise<LocationSubscription> {\n const watchId = HeadingSubscriber.registerCallback(callback);\n await ExpoLocation.watchDeviceHeading(watchId);\n\n return {\n remove() {\n HeadingSubscriber.unregisterCallback(watchId);\n },\n };\n}\n\n/**\n * Geocodes given address to an array of latitude-longitude coordinates.\n */\nexport async function geocodeAsync(\n address: string,\n options?: LocationGeocodingOptions\n): Promise<LocationGeocodedLocation[]> {\n if (typeof address !== 'string') {\n throw new TypeError(`Address to geocode must be a string. Got ${address} instead.`);\n }\n if (options?.useGoogleMaps || Platform.OS === 'web') {\n return await googleGeocodeAsync(address);\n }\n return await ExpoLocation.geocodeAsync(address);\n}\n\n/**\n * The opposite behavior of `geocodeAsync` — translates location coordinates to an array of addresses.\n */\nexport async function reverseGeocodeAsync(\n location: Pick<LocationGeocodedLocation, 'latitude' | 'longitude'>,\n options?: LocationGeocodingOptions\n): Promise<LocationGeocodedAddress[]> {\n if (typeof location.latitude !== 'number' || typeof location.longitude !== 'number') {\n throw new TypeError(\n 'Location to reverse-geocode must be an object with number properties `latitude` and `longitude`.'\n );\n }\n if (options?.useGoogleMaps || Platform.OS === 'web') {\n return await googleReverseGeocodeAsync(location);\n }\n return await ExpoLocation.reverseGeocodeAsync(location);\n}\n\n/**\n * Gets the current state of location permissions.\n * @deprecated Use `getForegroundPermissionsAsync()` or `getBackgroundPermissionsAsync()` instead.\n */\nexport async function getPermissionsAsync(): Promise<LocationPermissionResponse> {\n console.warn(\n `\"getPermissionsAsync()\" is now deprecated. Please use \"getForegroundPermissionsAsync()\" or \"getBackgroundPermissionsAsync()\" instead.`\n );\n return await ExpoLocation.getPermissionsAsync();\n}\n\n/**\n * Requests the user to grant location permissions.\n * @deprecated Use `requestForegroundPermissionsAsync()` or `requestBackgroundPermissionsAsync()` instead.\n */\nexport async function requestPermissionsAsync(): Promise<LocationPermissionResponse> {\n console.warn(\n `\"requestPermissionsAsync()\" is now deprecated. Please use \"requestForegroundPermissionsAsync()\" or \"requestBackgroundPermissionsAsync()\" instead.`\n );\n\n return await ExpoLocation.requestPermissionsAsync();\n}\n\n/**\n * Gets the current state of foreground location permissions.\n */\nexport async function getForegroundPermissionsAsync(): Promise<LocationPermissionResponse> {\n return await ExpoLocation.getForegroundPermissionsAsync();\n}\n\n/**\n * Requests the user to grant foreground location permissions.\n */\nexport async function requestForegroundPermissionsAsync(): Promise<LocationPermissionResponse> {\n return await ExpoLocation.requestForegroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Check or request permissions for the foreground location.\n * This uses both `requestForegroundPermissionsAsync` and `getForegroundPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Location.useForegroundPermissions();\n * ```\n */\nexport const useForegroundPermissions = createPermissionHook({\n getMethod: getForegroundPermissionsAsync,\n requestMethod: requestForegroundPermissionsAsync,\n});\n\n/**\n * Gets the current state of background location permissions.\n */\nexport async function getBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return await ExpoLocation.getBackgroundPermissionsAsync();\n}\n\n/**\n * Requests the user to grant background location permissions.\n */\nexport async function requestBackgroundPermissionsAsync(): Promise<PermissionResponse> {\n return await ExpoLocation.requestBackgroundPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Check or request permissions for the foreground location.\n * This uses both `requestBackgroundPermissionsAsync` and `getBackgroundPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Location.useBackgroundPermissions();\n * ```\n */\nexport const useBackgroundPermissions = createPermissionHook({\n getMethod: getBackgroundPermissionsAsync,\n requestMethod: requestBackgroundPermissionsAsync,\n});\n\n// --- Location service\n\n/**\n * Returns `true` if the device has location services enabled or `false` otherwise.\n */\nexport async function hasServicesEnabledAsync(): Promise<boolean> {\n return await ExpoLocation.hasServicesEnabledAsync();\n}\n\n// --- Background location updates\n\nfunction _validateTaskName(taskName: string) {\n if (!taskName || typeof taskName !== 'string') {\n throw new Error(`\\`taskName\\` must be a non-empty string. Got ${taskName} instead.`);\n }\n}\n\nexport async function isBackgroundLocationAvailableAsync(): Promise<boolean> {\n const providerStatus = await getProviderStatusAsync();\n return providerStatus.backgroundModeEnabled;\n}\n\nexport async function startLocationUpdatesAsync(\n taskName: string,\n options: LocationTaskOptions = { accuracy: LocationAccuracy.Balanced }\n): Promise<void> {\n _validateTaskName(taskName);\n await ExpoLocation.startLocationUpdatesAsync(taskName, options);\n}\n\nexport async function stopLocationUpdatesAsync(taskName: string): Promise<void> {\n _validateTaskName(taskName);\n await ExpoLocation.stopLocationUpdatesAsync(taskName);\n}\n\nexport async function hasStartedLocationUpdatesAsync(taskName: string): Promise<boolean> {\n _validateTaskName(taskName);\n return ExpoLocation.hasStartedLocationUpdatesAsync(taskName);\n}\n\n// --- Geofencing\n\nfunction _validateRegions(regions: LocationRegion[]) {\n if (!regions || regions.length === 0) {\n throw new Error(\n 'Regions array cannot be empty. Use `stopGeofencingAsync` if you want to stop geofencing all regions'\n );\n }\n for (const region of regions) {\n if (typeof region.latitude !== 'number') {\n throw new TypeError(`Region's latitude must be a number. Got '${region.latitude}' instead.`);\n }\n if (typeof region.longitude !== 'number') {\n throw new TypeError(\n `Region's longitude must be a number. Got '${region.longitude}' instead.`\n );\n }\n if (typeof region.radius !== 'number') {\n throw new TypeError(`Region's radius must be a number. Got '${region.radius}' instead.`);\n }\n }\n}\n\nexport async function startGeofencingAsync(\n taskName: string,\n regions: LocationRegion[] = []\n): Promise<void> {\n _validateTaskName(taskName);\n _validateRegions(regions);\n await ExpoLocation.startGeofencingAsync(taskName, { regions });\n}\n\nexport async function stopGeofencingAsync(taskName: string): Promise<void> {\n _validateTaskName(taskName);\n await ExpoLocation.stopGeofencingAsync(taskName);\n}\n\nexport async function hasStartedGeofencingAsync(taskName: string): Promise<boolean> {\n _validateTaskName(taskName);\n return ExpoLocation.hasStartedGeofencingAsync(taskName);\n}\n\n/**\n * @deprecated\n * Deprecated as of SDK39 in favour of `setGoogleApiKey`.\n */\nexport function setApiKey(apiKey: string): void {\n console.warn(\"Location's method `setApiKey` is deprecated in favor of `setGoogleApiKey`.\");\n setGoogleApiKey(apiKey);\n}\n\n// For internal purposes\nexport { LocationEventEmitter as EventEmitter, _getCurrentWatchId };\n\n// Export as namespaced types.\nexport {\n LocationAccuracy as Accuracy,\n LocationActivityType as ActivityType,\n LocationGeofencingEventType as GeofencingEventType,\n LocationGeofencingRegionState as GeofencingRegionState,\n PermissionStatus,\n PermissionHookOptions,\n setGoogleApiKey,\n};\n\nexport { installWebGeolocationPolyfill } from './GeolocationPolyfill';\nexport * from './Location.types';\n"]}
@@ -1,2 +1,2 @@
1
- import { EventEmitter } from '@unimodules/core';
1
+ import { EventEmitter } from 'expo-modules-core';
2
2
  export declare const LocationEventEmitter: EventEmitter;
@@ -1,4 +1,4 @@
1
- import { EventEmitter } from '@unimodules/core';
1
+ import { EventEmitter } from 'expo-modules-core';
2
2
  import ExpoLocation from './ExpoLocation';
3
3
  export const LocationEventEmitter = new EventEmitter(ExpoLocation);
4
4
  //# sourceMappingURL=LocationEventEmitter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocationEventEmitter.js","sourceRoot":"","sources":["../src/LocationEventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { EventEmitter } from '@unimodules/core';\n\nimport ExpoLocation from './ExpoLocation';\n\nexport const LocationEventEmitter = new EventEmitter(ExpoLocation);\n"]}
1
+ {"version":3,"file":"LocationEventEmitter.js","sourceRoot":"","sources":["../src/LocationEventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { EventEmitter } from 'expo-modules-core';\n\nimport ExpoLocation from './ExpoLocation';\n\nexport const LocationEventEmitter = new EventEmitter(ExpoLocation);\n"]}
@@ -1,2 +1,2 @@
1
- import { EventEmitter } from '@unimodules/core';
1
+ import { EventEmitter } from 'expo-modules-core';
2
2
  export declare const LocationEventEmitter: EventEmitter;
@@ -1,3 +1,3 @@
1
- import { EventEmitter } from '@unimodules/core';
1
+ import { EventEmitter } from 'expo-modules-core';
2
2
  export const LocationEventEmitter = new EventEmitter({});
3
3
  //# sourceMappingURL=LocationEventEmitter.web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocationEventEmitter.web.js","sourceRoot":"","sources":["../src/LocationEventEmitter.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAAC,EAAS,CAAC,CAAC","sourcesContent":["import { EventEmitter } from '@unimodules/core';\n\nexport const LocationEventEmitter = new EventEmitter({} as any);\n"]}
1
+ {"version":3,"file":"LocationEventEmitter.web.js","sourceRoot":"","sources":["../src/LocationEventEmitter.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,YAAY,CAAC,EAAS,CAAC,CAAC","sourcesContent":["import { EventEmitter } from 'expo-modules-core';\n\nexport const LocationEventEmitter = new EventEmitter({} as any);\n"]}