expo-location 58.0.13 → 58.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/AndroidManifest.xml +4 -0
  4. package/android/src/main/java/expo/modules/location/next/LocationModuleNext.kt +189 -10
  5. package/android/src/main/java/expo/modules/location/next/LocationPermissions.kt +65 -0
  6. package/android/src/main/java/expo/modules/location/next/LocationRecords.kt +91 -2
  7. package/android/src/main/java/expo/modules/location/next/LocationTaskConsumer.kt +205 -0
  8. package/android/src/main/java/expo/modules/location/next/WatchPosition.kt +8 -6
  9. package/android/src/main/java/expo/modules/location/next/locationForegroundService/BackgroundSessionOptions.kt +62 -0
  10. package/android/src/main/java/expo/modules/location/next/locationForegroundService/BackgroundSessionTypes.kt +32 -0
  11. package/android/src/main/java/expo/modules/location/next/locationForegroundService/ForegroundServiceExceptions.kt +53 -0
  12. package/android/src/main/java/expo/modules/location/next/locationForegroundService/LocationForegroundService.kt +142 -0
  13. package/android/src/main/java/expo/modules/location/next/locationForegroundService/ServiceNotification.kt +64 -0
  14. package/android/src/main/java/expo/modules/location/next/locationProviders/AndroidLocationProvider.kt +115 -7
  15. package/android/src/main/java/expo/modules/location/next/locationProviders/FallbackLocationProvider.kt +12 -3
  16. package/android/src/main/java/expo/modules/location/next/locationProviders/GmsLocationProvider.kt +79 -0
  17. package/android/src/main/java/expo/modules/location/next/locationProviders/LocationProvider.kt +48 -0
  18. package/android/src/main/java/expo/modules/location/taskConsumers/LocationTaskConsumer.kt +6 -0
  19. package/build/next/index.d.ts +1 -1
  20. package/build/next/index.js.map +1 -1
  21. package/build/next/js/LocationProvider.d.ts +35 -0
  22. package/build/next/js/LocationProvider.js +35 -6
  23. package/build/next/js/LocationProvider.js.map +1 -1
  24. package/build/next/js/LocationUpdatesHandle.d.ts +45 -7
  25. package/build/next/js/LocationUpdatesHandle.js +43 -7
  26. package/build/next/js/LocationUpdatesHandle.js.map +1 -1
  27. package/build/next/js/Permissions.d.ts +63 -0
  28. package/build/next/js/Permissions.js +63 -6
  29. package/build/next/js/Permissions.js.map +1 -1
  30. package/build/next/js/PositionWatchHandle.d.ts +78 -0
  31. package/build/next/js/PositionWatchHandle.js +78 -11
  32. package/build/next/js/PositionWatchHandle.js.map +1 -1
  33. package/build/next/js/getPosition.d.ts +26 -1
  34. package/build/next/js/getPosition.js +26 -2
  35. package/build/next/js/getPosition.js.map +1 -1
  36. package/build/next/js/locationServices.d.ts +29 -0
  37. package/build/next/js/locationServices.js +29 -3
  38. package/build/next/js/locationServices.js.map +1 -1
  39. package/build/next/types/LocationTask.types.d.ts +20 -0
  40. package/build/next/types/LocationTask.types.js +5 -0
  41. package/build/next/types/LocationTask.types.js.map +1 -0
  42. package/build/next/types/Permissions.types.d.ts +68 -0
  43. package/build/next/types/Permissions.types.js +51 -9
  44. package/build/next/types/Permissions.types.js.map +1 -1
  45. package/build/next/types/Position.types.d.ts +203 -2
  46. package/build/next/types/Position.types.js +51 -7
  47. package/build/next/types/Position.types.js.map +1 -1
  48. package/build/next/types/index.d.ts +1 -0
  49. package/build/next/types/index.js +1 -0
  50. package/build/next/types/index.js.map +1 -1
  51. package/ios/Providers/LocationsStreamer.swift +10 -4
  52. package/ios/TaskConsumers/EXGeofencingTaskConsumer.m +16 -1
  53. package/ios/next/LocationModuleNext.swift +4 -0
  54. package/ios/next/LocationNextExceptions.swift +0 -8
  55. package/ios/next/LocationUpdatesHandle/LocationUpdatesHandle.swift +6 -2
  56. package/ios/next/Position/LocationUpdateDiagnostics.swift +0 -3
  57. package/ios/next/Position/PositionUpdatesCompatibilitySource.swift +9 -1
  58. package/ios/next/Position/PositionUpdatesLiveSource.swift +5 -0
  59. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar +0 -0
  60. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.md5 +1 -0
  61. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha1 +1 -0
  62. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha256 +1 -0
  63. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha512 +1 -0
  64. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar +0 -0
  65. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.md5 +1 -0
  66. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha1 +1 -0
  67. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha256 +1 -0
  68. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha512 +1 -0
  69. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.13/expo.modules.location-58.0.13.module → 58.0.15/expo.modules.location-58.0.15.module} +22 -22
  70. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.md5 +1 -0
  71. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha1 +1 -0
  72. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha256 +1 -0
  73. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha512 +1 -0
  74. package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.13/expo.modules.location-58.0.13.pom → 58.0.15/expo.modules.location-58.0.15.pom} +1 -1
  75. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.md5 +1 -0
  76. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha1 +1 -0
  77. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha256 +1 -0
  78. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha512 +1 -0
  79. package/package.json +2 -2
  80. package/plugin/build/withLocation.js +2 -0
  81. package/plugin/build/withLocation.js.map +1 -1
  82. package/plugin/src/withLocation.ts +2 -0
  83. package/src/next/index.ts +1 -0
  84. package/src/next/js/LocationProvider.ts +35 -0
  85. package/src/next/js/LocationUpdatesHandle.ts +45 -8
  86. package/src/next/js/Permissions.ts +63 -0
  87. package/src/next/js/PositionWatchHandle.ts +78 -0
  88. package/src/next/js/getPosition.ts +29 -2
  89. package/src/next/js/locationServices.ts +29 -0
  90. package/src/next/types/LocationTask.types.ts +22 -0
  91. package/src/next/types/Permissions.types.ts +68 -0
  92. package/src/next/types/Position.types.ts +203 -2
  93. package/src/next/types/index.ts +1 -0
  94. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar +0 -0
  95. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.md5 +0 -1
  96. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha1 +0 -1
  97. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha256 +0 -1
  98. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13-sources.jar.sha512 +0 -1
  99. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar +0 -0
  100. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.md5 +0 -1
  101. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha1 +0 -1
  102. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha256 +0 -1
  103. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.aar.sha512 +0 -1
  104. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.md5 +0 -1
  105. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha1 +0 -1
  106. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha256 +0 -1
  107. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.module.sha512 +0 -1
  108. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.md5 +0 -1
  109. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha1 +0 -1
  110. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha256 +0 -1
  111. package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.13/expo.modules.location-58.0.13.pom.sha512 +0 -1
@@ -1,22 +1,90 @@
1
1
  import type { PermissionResponse } from 'expo';
2
2
  export declare enum LocationScope {
3
+ /**
4
+ * On Android, `ACCESS_BACKGROUND_LOCATION` is granted.
5
+ *
6
+ * On iOS, the authorization is `Always`.
7
+ */
3
8
  ALWAYS = "always",
9
+ /**
10
+ * On Android, `ACCESS_FINE_LOCATION` or `ACCESS_COARSE_LOCATION` is granted, but not
11
+ * `ACCESS_BACKGROUND_LOCATION`.
12
+ *
13
+ * On iOS, the authorization is `When In Use`.
14
+ */
4
15
  WHEN_IN_USE = "whenInUse",
16
+ /**
17
+ * The app cannot read the location.
18
+ */
5
19
  NOT_GRANTED = "notGranted"
6
20
  }
7
21
  export declare enum LocationAccuracy {
22
+ /**
23
+ * The app receives the precise location.
24
+ *
25
+ * On Android, `ACCESS_FINE_LOCATION` is granted.
26
+ *
27
+ * On iOS, **Precise Location** is turned on for the app.
28
+ */
8
29
  FULL = "full",
30
+ /**
31
+ * The app receives an approximate location, accurate to kilometers rather than meters.
32
+ *
33
+ * On Android, only `ACCESS_COARSE_LOCATION` is granted.
34
+ *
35
+ * On iOS, **Precise Location** is turned off for the app.
36
+ */
9
37
  REDUCED = "reduced",
38
+ /**
39
+ * The app cannot read the location.
40
+ */
10
41
  NOT_GRANTED = "notGranted"
11
42
  }
43
+ /**
44
+ * The accuracy a permission request asks for.
45
+ */
12
46
  export declare enum RequestPermissionsAccuracyOption {
47
+ /**
48
+ * Asks for the precise location.
49
+ *
50
+ * On Android, requests `ACCESS_FINE_LOCATION` together with `ACCESS_COARSE_LOCATION`.
51
+ *
52
+ * On iOS, when the app holds a reduced accuracy, shows the system prompt for temporary full
53
+ * accuracy after the permission is granted. The prompt needs the purpose string the config plugin
54
+ * writes by default; `locationFullAccuracyPermission: false` removes it and skips the prompt.
55
+ */
13
56
  FULL = "full",
57
+ /**
58
+ * Asks for an approximate location only.
59
+ *
60
+ * On Android, requests `ACCESS_COARSE_LOCATION` alone, so the system dialog does not offer the
61
+ * precise option.
62
+ *
63
+ * On iOS, never asks to raise a reduced accuracy.
64
+ */
14
65
  REDUCED = "reduced"
15
66
  }
67
+ /**
68
+ * Returned by the permission functions, with the location-specific `scope` and `accuracy`.
69
+ */
16
70
  export type LocationPermissionResponse = PermissionResponse & {
71
+ /**
72
+ * When the app can read the location: always, only while in use, or not at all.
73
+ */
17
74
  scope: LocationScope;
75
+ /**
76
+ * Whether the app receives the precise or an approximate location.
77
+ */
18
78
  accuracy: LocationAccuracy;
19
79
  };
80
+ /**
81
+ * Options for [`requestForegroundPermissions`](#requestforegroundpermissionsoptions) and
82
+ * [`requestBackgroundPermissions`](#requestbackgroundpermissionsoptions).
83
+ */
20
84
  export type RequestPermissionsOptions = {
85
+ /**
86
+ * The accuracy to ask for. Ignored by `requestBackgroundPermissions` on Android.
87
+ * @default RequestPermissionsAccuracyOption.FULL
88
+ */
21
89
  accuracy?: RequestPermissionsAccuracyOption;
22
90
  };
@@ -1,18 +1,60 @@
1
1
  export var LocationScope = /*#__PURE__*/ function(LocationScope) {
2
- LocationScope["ALWAYS"] = "always";
3
- LocationScope["WHEN_IN_USE"] = "whenInUse";
4
- LocationScope["NOT_GRANTED"] = "notGranted";
2
+ /**
3
+ * On Android, `ACCESS_BACKGROUND_LOCATION` is granted.
4
+ *
5
+ * On iOS, the authorization is `Always`.
6
+ */ LocationScope["ALWAYS"] = "always";
7
+ /**
8
+ * On Android, `ACCESS_FINE_LOCATION` or `ACCESS_COARSE_LOCATION` is granted, but not
9
+ * `ACCESS_BACKGROUND_LOCATION`.
10
+ *
11
+ * On iOS, the authorization is `When In Use`.
12
+ */ LocationScope["WHEN_IN_USE"] = "whenInUse";
13
+ /**
14
+ * The app cannot read the location.
15
+ */ LocationScope["NOT_GRANTED"] = "notGranted";
5
16
  return LocationScope;
6
17
  }({});
7
18
  export var LocationAccuracy = /*#__PURE__*/ function(LocationAccuracy) {
8
- LocationAccuracy["FULL"] = "full";
9
- LocationAccuracy["REDUCED"] = "reduced";
10
- LocationAccuracy["NOT_GRANTED"] = "notGranted";
19
+ /**
20
+ * The app receives the precise location.
21
+ *
22
+ * On Android, `ACCESS_FINE_LOCATION` is granted.
23
+ *
24
+ * On iOS, **Precise Location** is turned on for the app.
25
+ */ LocationAccuracy["FULL"] = "full";
26
+ /**
27
+ * The app receives an approximate location, accurate to kilometers rather than meters.
28
+ *
29
+ * On Android, only `ACCESS_COARSE_LOCATION` is granted.
30
+ *
31
+ * On iOS, **Precise Location** is turned off for the app.
32
+ */ LocationAccuracy["REDUCED"] = "reduced";
33
+ /**
34
+ * The app cannot read the location.
35
+ */ LocationAccuracy["NOT_GRANTED"] = "notGranted";
11
36
  return LocationAccuracy;
12
37
  }({});
13
- export var RequestPermissionsAccuracyOption = /*#__PURE__*/ function(RequestPermissionsAccuracyOption) {
14
- RequestPermissionsAccuracyOption["FULL"] = "full";
15
- RequestPermissionsAccuracyOption["REDUCED"] = "reduced";
38
+ /**
39
+ * The accuracy a permission request asks for.
40
+ */ export var RequestPermissionsAccuracyOption = /*#__PURE__*/ function(RequestPermissionsAccuracyOption) {
41
+ /**
42
+ * Asks for the precise location.
43
+ *
44
+ * On Android, requests `ACCESS_FINE_LOCATION` together with `ACCESS_COARSE_LOCATION`.
45
+ *
46
+ * On iOS, when the app holds a reduced accuracy, shows the system prompt for temporary full
47
+ * accuracy after the permission is granted. The prompt needs the purpose string the config plugin
48
+ * writes by default; `locationFullAccuracyPermission: false` removes it and skips the prompt.
49
+ */ RequestPermissionsAccuracyOption["FULL"] = "full";
50
+ /**
51
+ * Asks for an approximate location only.
52
+ *
53
+ * On Android, requests `ACCESS_COARSE_LOCATION` alone, so the system dialog does not offer the
54
+ * precise option.
55
+ *
56
+ * On iOS, never asks to raise a reduced accuracy.
57
+ */ RequestPermissionsAccuracyOption["REDUCED"] = "reduced";
16
58
  return RequestPermissionsAccuracyOption;
17
59
  }({});
18
60
 
@@ -1 +1 @@
1
- {"version":3,"sources":["next/types/Permissions.types.ts"],"sourcesContent":[null],"names":["LocationScope","LocationAccuracy","RequestPermissionsAccuracyOption"],"mappings":"AAEA,OAAO,IAAA,AAAKA,uCAAAA;;;;WAAAA;MAIX;AAED,OAAO,IAAA,AAAKC,0CAAAA;;;;WAAAA;MAIX;AAED,OAAO,IAAA,AAAKC,0DAAAA;;;WAAAA;MAGX"}
1
+ {"version":3,"sources":["next/types/Permissions.types.ts"],"sourcesContent":[null],"names":["LocationScope","LocationAccuracy","RequestPermissionsAccuracyOption"],"mappings":"AAEA,OAAO,IAAA,AAAKA,uCAAAA;IACV;;;;GAIC;IAED;;;;;GAKC;IAED;;GAEC;WAhBSA;MAkBX;AAED,OAAO,IAAA,AAAKC,0CAAAA;IACV;;;;;;GAMC;IAED;;;;;;GAMC;IAED;;GAEC;WAnBSA;MAqBX;AAED;;CAEC,GACD,OAAO,IAAA,AAAKC,0DAAAA;IACV;;;;;;;;GAQC;IAED;;;;;;;GAOC;WAlBSA;MAoBX"}
@@ -1,37 +1,206 @@
1
+ /**
2
+ * A use case that each platform turns into an accuracy, an update interval, and a power budget.
3
+ *
4
+ * On Android it maps to a `LocationRequest` priority and interval.
5
+ *
6
+ * On iOS 17 and later it maps to a `CLLocationUpdate.LiveConfiguration`; on earlier versions to a
7
+ * `CLLocationManager` activity type with the best available accuracy.
8
+ */
1
9
  export declare enum LocationProfile {
10
+ /**
11
+ * General-purpose positioning, for anything the other profiles do not cover.
12
+ *
13
+ * On Android, balanced priority with updates about every 5 seconds.
14
+ *
15
+ * On iOS, `CLLocationUpdate.LiveConfiguration.default`.
16
+ */
2
17
  DEFAULT = "default",
18
+ /**
19
+ * Turn-by-turn navigation in a vehicle.
20
+ *
21
+ * On Android, high accuracy with updates about every second.
22
+ *
23
+ * On iOS, `CLLocationUpdate.LiveConfiguration.automotiveNavigation`.
24
+ */
3
25
  AUTOMOTIVE_NAVIGATION = "automotiveNavigation",
26
+ /**
27
+ * Navigation on foot, by bike, or on water.
28
+ *
29
+ * On Android, high accuracy with updates about every 2 seconds.
30
+ *
31
+ * On iOS, `CLLocationUpdate.LiveConfiguration.otherNavigation`.
32
+ */
4
33
  OTHER_NAVIGATION = "otherNavigation",
34
+ /**
35
+ * Workout tracking such as running or cycling.
36
+ *
37
+ * On Android, high accuracy with updates about every 2 seconds.
38
+ *
39
+ * On iOS, `CLLocationUpdate.LiveConfiguration.fitness`.
40
+ */
5
41
  FITNESS = "fitness",
42
+ /**
43
+ * Flying, such as in a plane or a glider.
44
+ *
45
+ * On Android, high accuracy with updates about every second.
46
+ *
47
+ * On iOS, `CLLocationUpdate.LiveConfiguration.airborne`.
48
+ */
6
49
  AIRBORNE = "airborne",
50
+ /**
51
+ * Coarse position at the lowest power use.
52
+ *
53
+ * On Android, low-power priority with updates about every 60 seconds, which the provider can
54
+ * delay by up to 5 minutes and deliver in batches.
55
+ *
56
+ * On iOS, kilometer accuracy with a 3 km distance filter, on every iOS version.
57
+ */
7
58
  LOW_POWER = "lowPower"
8
59
  }
60
+ /**
61
+ * A set of coordinates expressed in decimal degrees.
62
+ * @example
63
+ * ```ts
64
+ * {
65
+ * latitude: 40.7128,
66
+ * longitude: -74.0060
67
+ * }
68
+ * ```
69
+ */
9
70
  export type Coordinates = {
10
71
  latitude: number;
11
72
  longitude: number;
12
73
  };
74
+ /**
75
+ * A single location fix.
76
+ * @example
77
+ * ```ts
78
+ * {
79
+ * coordinates: { latitude: 50.0614, longitude: 19.9372 },
80
+ * horizontalAccuracy: 12.5, // meters
81
+ * timestamp: 1791277756380, // milliseconds since the Unix epoch
82
+ * altitude: 253.1, // meters above the WGS 84 ellipsoid
83
+ * mslAltitude: 212.4, // meters above mean sea level
84
+ * verticalAccuracy: 4.8, // meters
85
+ * mocked: false,
86
+ * heading: 87.3, // degrees clockwise from true north, course over ground
87
+ * headingAccuracy: 5, // degrees
88
+ * speed: 1.4, // meters per second
89
+ * speedAccuracy: 0.3, // meters per second
90
+ * }
91
+ * ```
92
+ */
13
93
  export type Position = {
94
+ /**
95
+ * The latitude and longitude of the fix, in degrees.
96
+ */
14
97
  coordinates: Coordinates;
98
+ /**
99
+ * The radius around `coordinates` within which the device is, in meters.
100
+ */
15
101
  horizontalAccuracy: number | null;
102
+ /**
103
+ * When the fix was taken, in milliseconds since the Unix epoch. Check it when the position must
104
+ * be fresh, because a fix can be older than the moment it was delivered.
105
+ */
16
106
  timestamp: number;
107
+ /**
108
+ * Height above the WGS 84 ellipsoid, in meters.
109
+ */
17
110
  altitude: number | null;
111
+ /**
112
+ * Height above mean sea level, in meters.
113
+ *
114
+ * @platform android 14+
115
+ * @platform ios
116
+ */
18
117
  mslAltitude: number | null;
118
+ /**
119
+ * The uncertainty of `altitude` and `mslAltitude`, in meters.
120
+ *
121
+ * @platform android 8+
122
+ * @platform ios
123
+ */
19
124
  verticalAccuracy: number | null;
125
+ /**
126
+ * Whether the fix comes from a simulated source, such as a simulator or a mock location app.
127
+ *
128
+ * On Android it maps to `Location.isMock` on Android 12 and later and to
129
+ * `Location.isFromMockProvider()` on earlier versions; on iOS to
130
+ * `CLLocation.sourceInformation.isSimulatedBySoftware`.
131
+ */
20
132
  mocked: boolean;
133
+ /**
134
+ * The direction in which the device is traveling, in degrees clockwise from true north,
135
+ * from `0` to `360`. It is unrelated to the device's orientation.
136
+ */
21
137
  heading: number | null;
138
+ /**
139
+ * The uncertainty of `heading`, in degrees.
140
+ *
141
+ * @platform android 8+
142
+ * @platform ios
143
+ */
22
144
  headingAccuracy: number | null;
145
+ /**
146
+ * The speed, in meters per second.
147
+ */
23
148
  speed: number | null;
149
+ /**
150
+ * The uncertainty of `speed`, in meters per second.
151
+ *
152
+ * @platform android 8+
153
+ * @platform ios
154
+ */
24
155
  speedAccuracy: number | null;
25
156
  };
157
+ /**
158
+ * Options for [`getPosition`](#getpositiongetpositionoptions).
159
+ */
26
160
  export type GetPositionOptions = {
161
+ /**
162
+ * The maximum age of a cached location that may be returned.
163
+ * Expressed in seconds.
164
+ *
165
+ * If no new fix arrives within the timeout, `getPosition` returns the cached location
166
+ * regardless of its age.
167
+ * @default 0
168
+ */
27
169
  maxCachedAge?: number;
170
+ /**
171
+ * The maximum time to wait for a new location fix.
172
+ * Expressed in seconds.
173
+ *
174
+ * With a `timeout` of `0`, `getPosition` returns the last known location, if available.
175
+ *
176
+ * On Android, the providers cap it at 30 seconds.
177
+ * @default 30
178
+ */
28
179
  timeout?: number;
180
+ /**
181
+ * The use case the fix is for. It changes the way the location is requested from the OS and can
182
+ * affect accuracy and power usage. On iOS, a reduced accuracy authorization limits the fix
183
+ * whatever the profile; see [Request an approximate location](#request-an-approximate-location).
184
+ * @default LocationProfile.DEFAULT
185
+ */
29
186
  profile?: LocationProfile;
30
187
  };
188
+ /**
189
+ * The reason a watcher stopped delivering positions, passed to `onError`.
190
+ */
31
191
  export type PositionWatchError = {
192
+ /**
193
+ * A stable identifier of the failure, for branching in code.
194
+ */
32
195
  code: string;
196
+ /**
197
+ * A description of the failure, for logs and error screens.
198
+ */
33
199
  message: string;
34
200
  };
201
+ /**
202
+ * One `positionChanged` event from the native watcher: a position or an error, never both.
203
+ */
35
204
  export type PositionUpdate = {
36
205
  data: Position;
37
206
  error: null;
@@ -39,17 +208,49 @@ export type PositionUpdate = {
39
208
  data: null;
40
209
  error: PositionWatchError;
41
210
  };
211
+ /**
212
+ * A snapshot of the watcher's flags, returned by `status()`.
213
+ */
42
214
  export type PositionWatchStatus = {
43
- /** Whether the provider is feeding positions right now. */
215
+ /**
216
+ * Whether the provider is feeding positions right now.
217
+ */
44
218
  isSubscribed: boolean;
45
- /** Whether the handle can still be brought back to sending. False only once released. */
219
+ /**
220
+ * Whether the handle can still be brought back to sending. False only once released.
221
+ */
46
222
  isHandleAlive: boolean;
223
+ /**
224
+ * Whether delivery has been started. On Android, it is `true` while at least one listener is
225
+ * attached.
226
+ */
47
227
  isStarted: boolean;
228
+ /**
229
+ * Whether `pause()` was called and `resume()` was not called yet.
230
+ */
48
231
  isPaused: boolean;
232
+ /**
233
+ * Whether the app is in the foreground. On Android, the watcher holds the system request only
234
+ * while it is `true`.
235
+ */
49
236
  isInForeground: boolean;
50
237
  };
238
+ /**
239
+ * The parameters of `watchPosition`.
240
+ */
51
241
  export type WatchPositionParams = {
242
+ /**
243
+ * The use case the positions are for. It selects the accuracy and the update rate.
244
+ * @default LocationProfile.DEFAULT
245
+ */
52
246
  profile?: LocationProfile;
247
+ /**
248
+ * Called with every delivered position.
249
+ */
53
250
  onPosition: (position: Position) => void;
251
+ /**
252
+ * Called when the watcher cannot deliver positions, for example when the provider refuses the
253
+ * request after the app returns to the foreground.
254
+ */
54
255
  onError?: (error: PositionWatchError) => void;
55
256
  };
@@ -1,10 +1,54 @@
1
- export var LocationProfile = /*#__PURE__*/ function(LocationProfile) {
2
- LocationProfile["DEFAULT"] = "default";
3
- LocationProfile["AUTOMOTIVE_NAVIGATION"] = "automotiveNavigation";
4
- LocationProfile["OTHER_NAVIGATION"] = "otherNavigation";
5
- LocationProfile["FITNESS"] = "fitness";
6
- LocationProfile["AIRBORNE"] = "airborne";
7
- LocationProfile["LOW_POWER"] = "lowPower";
1
+ /**
2
+ * A use case that each platform turns into an accuracy, an update interval, and a power budget.
3
+ *
4
+ * On Android it maps to a `LocationRequest` priority and interval.
5
+ *
6
+ * On iOS 17 and later it maps to a `CLLocationUpdate.LiveConfiguration`; on earlier versions to a
7
+ * `CLLocationManager` activity type with the best available accuracy.
8
+ */ export var LocationProfile = /*#__PURE__*/ function(LocationProfile) {
9
+ /**
10
+ * General-purpose positioning, for anything the other profiles do not cover.
11
+ *
12
+ * On Android, balanced priority with updates about every 5 seconds.
13
+ *
14
+ * On iOS, `CLLocationUpdate.LiveConfiguration.default`.
15
+ */ LocationProfile["DEFAULT"] = "default";
16
+ /**
17
+ * Turn-by-turn navigation in a vehicle.
18
+ *
19
+ * On Android, high accuracy with updates about every second.
20
+ *
21
+ * On iOS, `CLLocationUpdate.LiveConfiguration.automotiveNavigation`.
22
+ */ LocationProfile["AUTOMOTIVE_NAVIGATION"] = "automotiveNavigation";
23
+ /**
24
+ * Navigation on foot, by bike, or on water.
25
+ *
26
+ * On Android, high accuracy with updates about every 2 seconds.
27
+ *
28
+ * On iOS, `CLLocationUpdate.LiveConfiguration.otherNavigation`.
29
+ */ LocationProfile["OTHER_NAVIGATION"] = "otherNavigation";
30
+ /**
31
+ * Workout tracking such as running or cycling.
32
+ *
33
+ * On Android, high accuracy with updates about every 2 seconds.
34
+ *
35
+ * On iOS, `CLLocationUpdate.LiveConfiguration.fitness`.
36
+ */ LocationProfile["FITNESS"] = "fitness";
37
+ /**
38
+ * Flying, such as in a plane or a glider.
39
+ *
40
+ * On Android, high accuracy with updates about every second.
41
+ *
42
+ * On iOS, `CLLocationUpdate.LiveConfiguration.airborne`.
43
+ */ LocationProfile["AIRBORNE"] = "airborne";
44
+ /**
45
+ * Coarse position at the lowest power use.
46
+ *
47
+ * On Android, low-power priority with updates about every 60 seconds, which the provider can
48
+ * delay by up to 5 minutes and deliver in batches.
49
+ *
50
+ * On iOS, kilometer accuracy with a 3 km distance filter, on every iOS version.
51
+ */ LocationProfile["LOW_POWER"] = "lowPower";
8
52
  return LocationProfile;
9
53
  }({});
10
54
 
@@ -1 +1 @@
1
- {"version":3,"sources":["next/types/Position.types.ts"],"sourcesContent":[null],"names":["LocationProfile"],"mappings":"AAAA,OAAO,IAAA,AAAKA,yCAAAA;;;;;;;WAAAA;MAOX"}
1
+ {"version":3,"sources":["next/types/Position.types.ts"],"sourcesContent":[null],"names":["LocationProfile"],"mappings":"AAAA;;;;;;;CAOC,GACD,OAAO,IAAA,AAAKA,yCAAAA;IACV;;;;;;GAMC;IAED;;;;;;GAMC;IAED;;;;;;GAMC;IAED;;;;;;GAMC;IAED;;;;;;GAMC;IAED;;;;;;;GAOC;WAhDSA;MAkDX"}
@@ -1,3 +1,4 @@
1
1
  export * from './Position.types';
2
2
  export * from './Permissions.types';
3
3
  export * from './LocationProvider.types';
4
+ export * from './LocationTask.types';
@@ -1,5 +1,6 @@
1
1
  export * from './Position.types';
2
2
  export * from './Permissions.types';
3
3
  export * from './LocationProvider.types';
4
+ export * from './LocationTask.types';
4
5
 
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["next/types/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,2BAA2B"}
1
+ {"version":3,"sources":["next/types/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,2BAA2B;AACzC,cAAc,uBAAuB"}
@@ -51,11 +51,17 @@ internal class LocationsStreamer: BaseStreamer {
51
51
  // Ignore `locationUnknown` (code 0) as it might be a temporary issue.
52
52
  // The location manager will keep trying to obtain the location.
53
53
  // It's a common error on simulator when there is no default location set in the scheme.
54
- guard let clError = error as? CLError, clError.code != .locationUnknown else {
54
+ switch error {
55
+ case CLError.locationUnknown:
55
56
  return
57
+ case CLError.denied where manager.authorizationStatus == .authorizedWhenInUse && CLLocationManager.locationServicesEnabled():
58
+ // The system sends CLError.denied when an app with whenInUse permission moves to the background.
59
+ // Updates resume on their own once the app returns to the foreground, so this error is ignored.
60
+ return
61
+ default:
62
+ continuation?.finish(throwing: Exceptions.LocationUnavailable().causedBy(error))
63
+ locationsStream = nil
64
+ continuation = nil
56
65
  }
57
- continuation?.finish(throwing: Exceptions.LocationUnavailable().causedBy(error))
58
- locationsStream = nil
59
- continuation = nil
60
66
  }
61
67
  }
@@ -9,6 +9,9 @@
9
9
  #import <ExpoLocation/EXLocation.h>
10
10
  #import <ExpoLocation/EXGeofencingTaskConsumer.h>
11
11
 
12
+ // shared by geofences and beacon regions, see https://developer.apple.com/documentation/corelocation/monitoring-the-user-s-proximity-to-geographic-regions
13
+ static const NSUInteger EXMaxMonitoredRegions = 20;
14
+
12
15
  @interface EXGeofencingTaskConsumer ()
13
16
 
14
17
  @property (nonatomic, strong) CLLocationManager *locationManager;
@@ -77,7 +80,8 @@
77
80
  NSString *identifier = regionDict[@"identifier"] ?: [[NSUUID UUID] UUIDString];
78
81
  CLLocationDistance radius = [regionDict[@"radius"] doubleValue];
79
82
  CLLocationCoordinate2D center = [self.class coordinateFromDictionary:regionDict];
80
- BOOL notifyOnEntry = [self.class boolValueFrom:regionDict[@"notifyOnEntry"] defaultValue:YES];
83
+ id notifyOnEnterValue = regionDict[@"notifyOnEnter"] ?: regionDict[@"notifyOnEntry"];
84
+ BOOL notifyOnEntry = [self.class boolValueFrom:notifyOnEnterValue defaultValue:YES];
81
85
  BOOL notifyOnExit = [self.class boolValueFrom:regionDict[@"notifyOnExit"] defaultValue:YES];
82
86
 
83
87
  CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:center radius:radius identifier:identifier];
@@ -145,6 +149,9 @@
145
149
  - (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
146
150
  {
147
151
  if (error && error.domain == kCLErrorDomain) {
152
+ if ([self isRegionRejectedByLimit:region]) {
153
+ return;
154
+ }
148
155
  // This error might happen when the device is not able to find out the location. Try to restart monitoring this region.
149
156
  [_locationManager stopMonitoringForRegion:region];
150
157
  [_locationManager startMonitoringForRegion:region];
@@ -164,6 +171,14 @@
164
171
 
165
172
  # pragma mark - helpers
166
173
 
174
+ - (BOOL)isRegionRejectedByLimit:(CLRegion *)region
175
+ {
176
+ NSSet<CLRegion *> *monitored = _locationManager.monitoredRegions;
177
+ BOOL isRegionMonitored = [monitored containsObject:region];
178
+ BOOL isMaxCountReached = monitored.count >= EXMaxMonitoredRegions;
179
+ return isMaxCountReached && !isRegionMonitored;
180
+ }
181
+
167
182
  - (CLRegionState)regionStateForIdentifier:(NSString *)identifier
168
183
  {
169
184
  return [_regionStates[identifier] integerValue];
@@ -28,6 +28,10 @@ public final class LocationModuleNext: Module {
28
28
  try permissions.requestBackgroundPermissions(options: options ?? PermissionsRequestOptions(), promise)
29
29
  }
30
30
 
31
+ Function("hasLocationServicesEnabled") { () -> Bool in
32
+ CLLocationManager.locationServicesEnabled()
33
+ }
34
+
31
35
  AsyncFunction("getPosition") { (options: GetPositionOptions?) -> Position? in
32
36
  guard CLLocationManager.locationServicesEnabled() else {
33
37
  throw LocationServicesDisabledGlobally()
@@ -36,14 +36,6 @@ final class LocationAuthorizationRestricted: Exception, @unchecked Sendable {
36
36
  }
37
37
  }
38
38
 
39
- final class LocationServiceSessionRequired: Exception, @unchecked Sendable {
40
- override var reason: String {
41
- "Location updates stopped because this app sets 'CLRequireExplicitServiceSession' in its " +
42
- "Info.plist, which makes the system refuse updates unless the app holds a CLServiceSession. " +
43
- "'expo-location' does not create one. Remove that key from your Info.plist, or manage the session " +
44
- "yourself and use CoreLocation directly"
45
- }
46
- }
47
39
 
48
40
  final class LocationUpdatesEndedUnexpectedly: Exception, @unchecked Sendable {
49
41
  override var reason: String {
@@ -36,11 +36,15 @@ final class LocationUpdatesHandle: SharedObject {
36
36
  }
37
37
 
38
38
  func stop() throws {
39
- try taskManager().unregisterTask(withName: taskName, consumerClass: LocationUpdatesTaskConsumer.self)
39
+ let taskManager = try taskManager()
40
+ guard taskManager.task(withName: taskName, hasConsumerOf: LocationUpdatesTaskConsumer.self) else {
41
+ return
42
+ }
43
+ taskManager.unregisterTask(withName: taskName, consumerClass: LocationUpdatesTaskConsumer.self)
40
44
  }
41
45
 
42
46
  func hasStarted() throws -> Bool {
43
- return try taskManager().hasRegisteredTask(withName: taskName)
47
+ return try taskManager().task(withName: taskName, hasConsumerOf: LocationUpdatesTaskConsumer.self)
44
48
  }
45
49
 
46
50
  private func taskManager() throws -> EXTaskManagerInterface {
@@ -19,9 +19,6 @@ struct LocationUpdateDiagnostics {
19
19
  if authorizationDenied {
20
20
  return LocationAuthorizationDenied()
21
21
  }
22
- if serviceSessionRequired {
23
- return LocationServiceSessionRequired()
24
- }
25
22
  return nil
26
23
  }
27
24
  }
@@ -1,7 +1,9 @@
1
1
  import CoreLocation
2
2
 
3
3
  final class PositionUpdatesCompatibilitySource: NSObject, CLLocationManagerDelegate {
4
- private lazy var manager = CLLocationManager()
4
+ var makeManager: () -> CLLocationManager = { CLLocationManager() }
5
+ var isLocationServicesEnabled: () -> Bool = CLLocationManager.locationServicesEnabled
6
+ private lazy var manager = makeManager()
5
7
  private var continuation: AsyncThrowingStream<CLLocation?, Error>.Continuation?
6
8
 
7
9
  func updates(for profile: Profile, allowsBackgroundUpdates: Bool = false) -> PositionUpdatesSource {
@@ -34,6 +36,12 @@ final class PositionUpdatesCompatibilitySource: NSObject, CLLocationManagerDeleg
34
36
  switch error {
35
37
  case CLError.locationUnknown:
36
38
  return
39
+ case CLError.denied where !isLocationServicesEnabled():
40
+ continuation?.finish(throwing: LocationServicesDisabledGlobally())
41
+ case CLError.denied where manager.authorizationStatus == .authorizedWhenInUse:
42
+ // The system sends CLError.denied when an app with whenInUse permission moves to the background.
43
+ // Updates resume on their own once the app returns to the foreground, so this error is ignored.
44
+ return
37
45
  case CLError.denied:
38
46
  continuation?.finish(throwing: LocationAuthorizationDenied())
39
47
  default:
@@ -12,6 +12,11 @@ final class PositionUpdatesLiveSource {
12
12
  guard !Task.isCancelled else {
13
13
  break
14
14
  }
15
+ // Drop once iOS 17 support ends: from iOS 18 CLLocationUpdate reports this itself through authorizationDeniedGlobally.
16
+ if #unavailable(iOS 18.0), !CLLocationManager.locationServicesEnabled() {
17
+ continuation.finish(throwing: LocationServicesDisabledGlobally())
18
+ return
19
+ }
15
20
  if #available(iOS 18.0, *), let failure = LocationUpdateDiagnostics(update).unrecoverableFailure() {
16
21
  continuation.finish(throwing: failure)
17
22
  return