expo-location 58.0.14 → 58.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/location/taskConsumers/LocationTaskConsumer.kt +62 -4
- package/build/next/Location.d.ts +1 -1
- package/build/next/Location.js +1 -1
- package/build/next/Location.js.map +1 -1
- package/build/next/index.d.ts +2 -2
- package/build/next/index.js +2 -2
- package/build/next/index.js.map +1 -1
- package/build/next/js/BackgroundSession.d.ts +44 -0
- package/build/next/js/BackgroundSession.js +49 -0
- package/build/next/js/BackgroundSession.js.map +1 -0
- package/build/next/js/LocationProvider.d.ts +36 -0
- package/build/next/js/LocationProvider.js +36 -6
- package/build/next/js/LocationProvider.js.map +1 -1
- package/build/next/js/LocationUpdatesHandle.d.ts +57 -7
- package/build/next/js/LocationUpdatesHandle.js +56 -7
- package/build/next/js/LocationUpdatesHandle.js.map +1 -1
- package/build/next/js/Permissions.d.ts +89 -0
- package/build/next/js/Permissions.js +99 -6
- package/build/next/js/Permissions.js.map +1 -1
- package/build/next/js/PositionWatchHandle.d.ts +89 -0
- package/build/next/js/PositionWatchHandle.js +89 -11
- package/build/next/js/PositionWatchHandle.js.map +1 -1
- package/build/next/js/getPosition.d.ts +29 -1
- package/build/next/js/getPosition.js +29 -2
- package/build/next/js/getPosition.js.map +1 -1
- package/build/next/js/index.d.ts +2 -1
- package/build/next/js/index.js +2 -1
- package/build/next/js/index.js.map +1 -1
- package/build/next/js/locationServices.d.ts +30 -0
- package/build/next/js/locationServices.js +30 -3
- package/build/next/js/locationServices.js.map +1 -1
- package/build/next/native/NativeLocationModuleNext.d.ts +1 -0
- package/build/next/native/NativeLocationModuleNext.js +1 -0
- package/build/next/native/NativeLocationModuleNext.js.map +1 -1
- package/build/next/native/index.d.ts +2 -1
- package/build/next/native/index.js +1 -1
- package/build/next/native/index.js.map +1 -1
- package/build/next/native/types/NativeBackgroundSessionClass.types.d.ts +6 -0
- package/build/next/native/types/NativeBackgroundSessionClass.types.js +3 -0
- package/build/next/native/types/NativeBackgroundSessionClass.types.js.map +1 -0
- package/build/next/native/types/NativeLocationModuleNextClass.types.d.ts +5 -1
- package/build/next/native/types/NativeLocationUpdatesHandleClass.types.d.ts +2 -1
- package/build/next/native/types/NativeLocationUpdatesHandleClass.types.js.map +1 -1
- package/build/next/types/BackgroundSession.types.d.ts +56 -0
- package/build/next/types/BackgroundSession.types.js +18 -0
- package/build/next/types/BackgroundSession.types.js.map +1 -0
- package/build/next/types/LocationTask.types.d.ts +20 -0
- package/build/next/types/LocationTask.types.js +5 -0
- package/build/next/types/LocationTask.types.js.map +1 -0
- package/build/next/types/LocationUpdates.types.d.ts +18 -0
- package/build/next/types/LocationUpdates.types.js +7 -0
- package/build/next/types/LocationUpdates.types.js.map +1 -0
- package/build/next/types/Permissions.types.d.ts +68 -0
- package/build/next/types/Permissions.types.js +51 -9
- package/build/next/types/Permissions.types.js.map +1 -1
- package/build/next/types/Position.types.d.ts +223 -2
- package/build/next/types/Position.types.js +54 -7
- package/build/next/types/Position.types.js.map +1 -1
- package/build/next/types/index.d.ts +3 -0
- package/build/next/types/index.js +3 -0
- package/build/next/types/index.js.map +1 -1
- package/ios/TaskConsumers/EXGeofencingTaskConsumer.m +16 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.14/expo.modules.location-58.0.14-sources.jar → 58.0.16/expo.modules.location-58.0.16-sources.jar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.14/expo.modules.location-58.0.14.aar → 58.0.16/expo.modules.location-58.0.16.aar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.14/expo.modules.location-58.0.14.module → 58.0.16/expo.modules.location-58.0.16.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.14/expo.modules.location-58.0.14.pom → 58.0.16/expo.modules.location-58.0.16.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.16/expo.modules.location-58.0.16.pom.sha512 +1 -0
- package/package.json +4 -4
- package/src/next/Location.ts +5 -0
- package/src/next/index.ts +6 -0
- package/src/next/js/BackgroundSession.ts +56 -0
- package/src/next/js/LocationProvider.ts +36 -0
- package/src/next/js/LocationUpdatesHandle.ts +65 -8
- package/src/next/js/Permissions.ts +108 -0
- package/src/next/js/PositionWatchHandle.ts +89 -0
- package/src/next/js/getPosition.ts +32 -2
- package/src/next/js/index.ts +8 -0
- package/src/next/js/locationServices.ts +30 -0
- package/src/next/native/NativeLocationModuleNext.ts +1 -0
- package/src/next/native/index.ts +2 -0
- package/src/next/native/types/NativeBackgroundSessionClass.types.ts +7 -0
- package/src/next/native/types/NativeLocationModuleNextClass.types.ts +5 -1
- package/src/next/native/types/NativeLocationUpdatesHandleClass.types.ts +2 -1
- package/src/next/types/BackgroundSession.types.ts +58 -0
- package/src/next/types/LocationTask.types.ts +22 -0
- package/src/next/types/LocationUpdates.types.ts +18 -0
- package/src/next/types/Permissions.types.ts +68 -0
- package/src/next/types/Position.types.ts +223 -2
- package/src/next/types/index.ts +3 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.14/expo.modules.location-58.0.14.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [Android] Don't crash when the foreground service of a location task can't be started, for example when the location permission was revoked while the task stayed registered. The task now keeps running without the service instead of crashing the app on every launch. ([#51216](https://github.com/expo/expo/pull/51216) by [@krisoft20](https://github.com/krisoft20))
|
|
8
|
+
- [Android] Add the TypeScript interface for the location foreground service: `ensureBackgroundSessionStarted`, `stopBackgroundSession` and `getBackgroundSessionStatus`.
|
|
9
|
+
|
|
10
|
+
Add `getNotificationPermissions`, `requestNotificationPermissions` and the `useNotificationPermissions` hook for the service's notification.
|
|
11
|
+
|
|
12
|
+
Add `LocationUpdatesHandle.status()`, and the `canDeliverUpdates` and `areUpdatesAllowed` fields on `PositionWatchStatus`.
|
|
13
|
+
|
|
14
|
+
([#51320](https://github.com/expo/expo/pull/51320) by [@HubertBer](https://github.com/HubertBer))
|
|
15
|
+
|
|
16
|
+
- Updated dependencies.
|
|
17
|
+
- @expo/image-utils@0.12.5
|
|
18
|
+
|
|
19
|
+
## 58.0.15
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [Android] Stop the location foreground service when a background location task is unregistered while the service is still binding, so a `stopLocationUpdatesAsync` that follows `startLocationUpdatesAsync` within milliseconds no longer leaves the service and its notification running. ([#51236](https://github.com/expo/expo/pull/51236) by [@jrceranornelson](https://github.com/jrceranornelson))
|
|
24
|
+
- [iOS] Fix `notifyOnEnter` being ignored for geofencing regions. The native side read a misspelled key, so every region reported enter events regardless of the flag. ([#51444](https://github.com/expo/expo/pull/51444) by [@Wenszel](https://github.com/Wenszel))
|
|
25
|
+
- [iOS] Fix an infinite region restart loop when geofencing exceeds the maximum number of monitored regions. ([#51443](https://github.com/expo/expo/pull/51443) by [@Wenszel](https://github.com/Wenszel))
|
|
26
|
+
- Add TSDoc to the `expo-location/next` API. ([#51231](https://github.com/expo/expo/pull/51231) by [@Wenszel](https://github.com/Wenszel))
|
|
27
|
+
|
|
3
28
|
## 58.0.14
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'host.exp.exponent'
|
|
7
|
-
version = '58.0.
|
|
7
|
+
version = '58.0.16'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.location"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 29
|
|
13
|
-
versionName "58.0.
|
|
13
|
+
versionName "58.0.16"
|
|
14
14
|
consumerProguardFiles("proguard-rules.pro")
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package expo.modules.location.taskConsumers
|
|
2
2
|
|
|
3
|
+
import android.Manifest
|
|
3
4
|
import android.app.PendingIntent
|
|
4
5
|
import android.app.job.JobParameters
|
|
5
6
|
import android.app.job.JobService
|
|
@@ -7,12 +8,14 @@ import android.content.ComponentName
|
|
|
7
8
|
import android.content.Context
|
|
8
9
|
import android.content.Intent
|
|
9
10
|
import android.content.ServiceConnection
|
|
11
|
+
import android.content.pm.PackageManager
|
|
10
12
|
import android.location.Location
|
|
11
13
|
import android.os.Build
|
|
12
14
|
import android.os.Bundle
|
|
13
15
|
import android.os.IBinder
|
|
14
16
|
import android.os.PersistableBundle
|
|
15
17
|
import android.util.Log
|
|
18
|
+
import androidx.core.content.ContextCompat
|
|
16
19
|
import com.google.android.gms.location.FusedLocationProviderClient
|
|
17
20
|
import com.google.android.gms.location.LocationRequest
|
|
18
21
|
import com.google.android.gms.location.LocationResult
|
|
@@ -37,6 +40,7 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
37
40
|
private var mTask: TaskInterface? = null
|
|
38
41
|
private var mPendingIntent: PendingIntent? = null
|
|
39
42
|
private var mService: LocationTaskService? = null
|
|
43
|
+
private var mServiceConnection: ServiceConnection? = null
|
|
40
44
|
private var mLocationRequest: LocationRequest? = null
|
|
41
45
|
private var mLastReportedLocation: Location? = null
|
|
42
46
|
private var mDeferredDistance = 0.0
|
|
@@ -204,6 +208,11 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
204
208
|
|
|
205
209
|
// Foreground service is requested but not running.
|
|
206
210
|
if (mService == null) {
|
|
211
|
+
// Android 14+ throws without a location permission, which can expire while the task stays registered.
|
|
212
|
+
if (!hasLocationPermission()) {
|
|
213
|
+
Log.w(TAG, "Foreground location task cannot be started without a location permission")
|
|
214
|
+
return
|
|
215
|
+
}
|
|
207
216
|
val serviceIntent = Intent(context, LocationTaskService::class.java)
|
|
208
217
|
val extras = Bundle()
|
|
209
218
|
val serviceOptions = options.getArguments(FOREGROUND_SERVICE_KEY).toBundle()
|
|
@@ -213,7 +222,15 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
213
222
|
extras.putString("taskName", task.name)
|
|
214
223
|
extras.putBoolean("killService", serviceOptions.getBoolean("killServiceOnDestroy", false))
|
|
215
224
|
serviceIntent.putExtras(extras)
|
|
216
|
-
|
|
225
|
+
try {
|
|
226
|
+
context.startForegroundService(serviceIntent)
|
|
227
|
+
} catch (e: RuntimeException) {
|
|
228
|
+
if (!isStartRejected(e)) {
|
|
229
|
+
throw e
|
|
230
|
+
}
|
|
231
|
+
Log.w(TAG, "Foreground location task could not be started", e)
|
|
232
|
+
return
|
|
233
|
+
}
|
|
217
234
|
context.bindService(
|
|
218
235
|
serviceIntent,
|
|
219
236
|
object : ServiceConnection {
|
|
@@ -221,7 +238,22 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
221
238
|
mService = (service as? ServiceBinder)?.service
|
|
222
239
|
mService?.let {
|
|
223
240
|
it.setParentContext(context)
|
|
224
|
-
|
|
241
|
+
try {
|
|
242
|
+
it.startForeground(serviceOptions)
|
|
243
|
+
} catch (e: RuntimeException) {
|
|
244
|
+
if (!isStartRejected(e)) {
|
|
245
|
+
throw e
|
|
246
|
+
}
|
|
247
|
+
Log.w(TAG, "Foreground location task could not enter the foreground", e)
|
|
248
|
+
releaseService()
|
|
249
|
+
return
|
|
250
|
+
}
|
|
251
|
+
// The task was unregistered while this bind was pending: didUnregister() found no
|
|
252
|
+
// service to stop. Stop it now. startForeground() above is still required, since the
|
|
253
|
+
// service was started with startForegroundService().
|
|
254
|
+
if (mTask == null) {
|
|
255
|
+
stopForegroundService()
|
|
256
|
+
}
|
|
225
257
|
}
|
|
226
258
|
}
|
|
227
259
|
|
|
@@ -229,12 +261,38 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
229
261
|
mService?.stop()
|
|
230
262
|
mService = null
|
|
231
263
|
}
|
|
232
|
-
},
|
|
264
|
+
}.also { mServiceConnection = it },
|
|
233
265
|
Context.BIND_AUTO_CREATE
|
|
234
266
|
)
|
|
235
267
|
} else {
|
|
236
268
|
// Restart the service with new service options.
|
|
237
|
-
|
|
269
|
+
try {
|
|
270
|
+
mService?.startForeground(options.getArguments(FOREGROUND_SERVICE_KEY).toBundle())
|
|
271
|
+
} catch (e: RuntimeException) {
|
|
272
|
+
if (!isStartRejected(e)) {
|
|
273
|
+
throw e
|
|
274
|
+
}
|
|
275
|
+
Log.w(TAG, "Foreground location task could not be restarted", e)
|
|
276
|
+
releaseService()
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// ForegroundServiceStartNotAllowedException and BackgroundServiceStartNotAllowedException are IllegalStateExceptions.
|
|
282
|
+
private fun isStartRejected(e: RuntimeException): Boolean {
|
|
283
|
+
return e is SecurityException || e is IllegalStateException
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
private fun releaseService() {
|
|
287
|
+
mService?.stop()
|
|
288
|
+
mService = null
|
|
289
|
+
mServiceConnection?.let { context.unbindService(it) }
|
|
290
|
+
mServiceConnection = null
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private fun hasLocationPermission(): Boolean {
|
|
294
|
+
return listOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION).any {
|
|
295
|
+
ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED
|
|
238
296
|
}
|
|
239
297
|
}
|
|
240
298
|
|
package/build/next/Location.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getPosition, watchPosition, hasLocationServicesEnabled, enableLocationServices, getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, setLocationProvider, getSelectedLocationProviderName, } from './js';
|
|
1
|
+
export { getPosition, watchPosition, hasLocationServicesEnabled, enableLocationServices, getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, getNotificationPermissions, requestNotificationPermissions, setLocationProvider, getSelectedLocationProviderName, ensureBackgroundSessionStarted, stopBackgroundSession, getBackgroundSessionStatus, } from './js';
|
package/build/next/Location.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { getPosition, watchPosition, hasLocationServicesEnabled, enableLocationServices, getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, setLocationProvider, getSelectedLocationProviderName } from './js';
|
|
1
|
+
export { getPosition, watchPosition, hasLocationServicesEnabled, enableLocationServices, getForegroundPermissions, requestForegroundPermissions, getBackgroundPermissions, requestBackgroundPermissions, getNotificationPermissions, requestNotificationPermissions, setLocationProvider, getSelectedLocationProviderName, ensureBackgroundSessionStarted, stopBackgroundSession, getBackgroundSessionStatus } from './js';
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=Location.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/Location.ts"],"sourcesContent":[null],"names":["getPosition","watchPosition","hasLocationServicesEnabled","enableLocationServices","getForegroundPermissions","requestForegroundPermissions","getBackgroundPermissions","requestBackgroundPermissions","setLocationProvider","getSelectedLocationProviderName"],"mappings":"AAAA,SACEA,WAAW,EACXC,aAAa,EACbC,0BAA0B,EAC1BC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,+BAA+B,
|
|
1
|
+
{"version":3,"sources":["next/Location.ts"],"sourcesContent":[null],"names":["getPosition","watchPosition","hasLocationServicesEnabled","enableLocationServices","getForegroundPermissions","requestForegroundPermissions","getBackgroundPermissions","requestBackgroundPermissions","getNotificationPermissions","requestNotificationPermissions","setLocationProvider","getSelectedLocationProviderName","ensureBackgroundSessionStarted","stopBackgroundSession","getBackgroundSessionStatus"],"mappings":"AAAA,SACEA,WAAW,EACXC,aAAa,EACbC,0BAA0B,EAC1BC,sBAAsB,EACtBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,8BAA8B,EAC9BC,mBAAmB,EACnBC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,qBAAqB,EACrBC,0BAA0B,QACrB,OAAO"}
|
package/build/next/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * as Location from './Location';
|
|
2
|
-
export { useForegroundLocationPermissions, useBackgroundLocationPermissions, useLocationServices, PositionWatchHandle, LocationProvider, LocationUpdatesHandle, defineLocationTask, } from './js';
|
|
3
|
-
export { LocationProfile, LocationAccuracy, LocationScope, RequestPermissionsAccuracyOption, type Coordinates, type Position, type PositionUpdate, type PositionWatchError, type PositionWatchStatus, type WatchPositionParams, type GetPositionOptions, type LocationPermissionResponse, type RequestPermissionsOptions, type LocationProviderRefType, } from './types';
|
|
2
|
+
export { useForegroundLocationPermissions, useBackgroundLocationPermissions, useNotificationPermissions, useLocationServices, PositionWatchHandle, LocationProvider, LocationUpdatesHandle, defineLocationTask, } from './js';
|
|
3
|
+
export { LocationProfile, LocationAccuracy, LocationScope, RequestPermissionsAccuracyOption, type Coordinates, type Position, type PositionUpdate, type PositionWatchError, type PositionWatchStatus, type WatchPositionParams, type GetPositionOptions, type LocationTaskOptions, type LocationPermissionResponse, type RequestPermissionsOptions, type LocationProviderRefType, BackgroundSessionState, type BackgroundSessionOptions, type BackgroundSessionStatus, type BackgroundTaskStatus, } from './types';
|
package/build/next/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * as Location from './Location';
|
|
2
|
-
export { useForegroundLocationPermissions, useBackgroundLocationPermissions, useLocationServices, PositionWatchHandle, LocationProvider, LocationUpdatesHandle, defineLocationTask } from './js';
|
|
3
|
-
export { LocationProfile, LocationAccuracy, LocationScope, RequestPermissionsAccuracyOption } from './types';
|
|
2
|
+
export { useForegroundLocationPermissions, useBackgroundLocationPermissions, useNotificationPermissions, useLocationServices, PositionWatchHandle, LocationProvider, LocationUpdatesHandle, defineLocationTask } from './js';
|
|
3
|
+
export { LocationProfile, LocationAccuracy, LocationScope, RequestPermissionsAccuracyOption, BackgroundSessionState } from './types';
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/build/next/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/index.ts"],"sourcesContent":[null],"names":["Location","useForegroundLocationPermissions","useBackgroundLocationPermissions","useLocationServices","PositionWatchHandle","LocationProvider","LocationUpdatesHandle","defineLocationTask","LocationProfile","LocationAccuracy","LocationScope","RequestPermissionsAccuracyOption"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,aAAa;AAEvC,SACEC,gCAAgC,EAChCC,gCAAgC,EAChCC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,qBAAqB,EACrBC,kBAAkB,QACb,OAAO;AAEd,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,gCAAgC,
|
|
1
|
+
{"version":3,"sources":["next/index.ts"],"sourcesContent":[null],"names":["Location","useForegroundLocationPermissions","useBackgroundLocationPermissions","useNotificationPermissions","useLocationServices","PositionWatchHandle","LocationProvider","LocationUpdatesHandle","defineLocationTask","LocationProfile","LocationAccuracy","LocationScope","RequestPermissionsAccuracyOption","BackgroundSessionState"],"mappings":"AAAA,OAAO,KAAKA,QAAQ,MAAM,aAAa;AAEvC,SACEC,gCAAgC,EAChCC,gCAAgC,EAChCC,0BAA0B,EAC1BC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,qBAAqB,EACrBC,kBAAkB,QACb,OAAO;AAEd,SACEC,eAAe,EACfC,gBAAgB,EAChBC,aAAa,EACbC,gCAAgC,EAYhCC,sBAAsB,QAIjB,UAAU"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BackgroundSessionOptions, BackgroundSessionStatus } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Starts the foreground service that keeps location updates flowing while the app is in the
|
|
4
|
+
* background. If the service is already promoted, re-posts its notification with the given
|
|
5
|
+
* options.
|
|
6
|
+
*
|
|
7
|
+
* Starting the service requires the app to be in the foreground. When no service is running, a
|
|
8
|
+
* call from the background rejects, but it still persists the `options`, so the service starts
|
|
9
|
+
* the next time the app comes to the foreground.
|
|
10
|
+
*
|
|
11
|
+
* The service keeps the `options` and restarts when the app is closed and reopened. Omitting
|
|
12
|
+
* `options` uses the persisted configuration, or the default one if unset.
|
|
13
|
+
*
|
|
14
|
+
* Does nothing on Android 7 and earlier, where background location is never throttled.
|
|
15
|
+
*
|
|
16
|
+
* A missing `POST_NOTIFICATIONS` permission is not an error. The service still runs, but its
|
|
17
|
+
* notification does not appear in the notification drawer.
|
|
18
|
+
*
|
|
19
|
+
* See [Start a background session](#start-a-background-session).
|
|
20
|
+
*
|
|
21
|
+
* @throws if the manifest is missing `FOREGROUND_SERVICE` or `FOREGROUND_SERVICE_LOCATION`,
|
|
22
|
+
* foreground location permission is not granted, the app is in the background with no service
|
|
23
|
+
* running, a previous session is still stopping, or promotion does not complete within four
|
|
24
|
+
* seconds.
|
|
25
|
+
*
|
|
26
|
+
* @platform android
|
|
27
|
+
*/
|
|
28
|
+
export declare function ensureBackgroundSessionStarted(options?: BackgroundSessionOptions): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Stops the foreground service and clears the persisted configuration.
|
|
31
|
+
*
|
|
32
|
+
* See [Start a background session](#start-a-background-session).
|
|
33
|
+
*
|
|
34
|
+
* @platform android
|
|
35
|
+
*/
|
|
36
|
+
export declare function stopBackgroundSession(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Reads the current state of the background session.
|
|
39
|
+
*
|
|
40
|
+
* See [Start a background session](#start-a-background-session).
|
|
41
|
+
*
|
|
42
|
+
* @platform android
|
|
43
|
+
*/
|
|
44
|
+
export declare function getBackgroundSessionStatus(): BackgroundSessionStatus;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NativeBackgroundSession } from '../native';
|
|
2
|
+
/**
|
|
3
|
+
* Starts the foreground service that keeps location updates flowing while the app is in the
|
|
4
|
+
* background. If the service is already promoted, re-posts its notification with the given
|
|
5
|
+
* options.
|
|
6
|
+
*
|
|
7
|
+
* Starting the service requires the app to be in the foreground. When no service is running, a
|
|
8
|
+
* call from the background rejects, but it still persists the `options`, so the service starts
|
|
9
|
+
* the next time the app comes to the foreground.
|
|
10
|
+
*
|
|
11
|
+
* The service keeps the `options` and restarts when the app is closed and reopened. Omitting
|
|
12
|
+
* `options` uses the persisted configuration, or the default one if unset.
|
|
13
|
+
*
|
|
14
|
+
* Does nothing on Android 7 and earlier, where background location is never throttled.
|
|
15
|
+
*
|
|
16
|
+
* A missing `POST_NOTIFICATIONS` permission is not an error. The service still runs, but its
|
|
17
|
+
* notification does not appear in the notification drawer.
|
|
18
|
+
*
|
|
19
|
+
* See [Start a background session](#start-a-background-session).
|
|
20
|
+
*
|
|
21
|
+
* @throws if the manifest is missing `FOREGROUND_SERVICE` or `FOREGROUND_SERVICE_LOCATION`,
|
|
22
|
+
* foreground location permission is not granted, the app is in the background with no service
|
|
23
|
+
* running, a previous session is still stopping, or promotion does not complete within four
|
|
24
|
+
* seconds.
|
|
25
|
+
*
|
|
26
|
+
* @platform android
|
|
27
|
+
*/ export async function ensureBackgroundSessionStarted(options) {
|
|
28
|
+
await NativeBackgroundSession.ensureStarted(options);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Stops the foreground service and clears the persisted configuration.
|
|
32
|
+
*
|
|
33
|
+
* See [Start a background session](#start-a-background-session).
|
|
34
|
+
*
|
|
35
|
+
* @platform android
|
|
36
|
+
*/ export async function stopBackgroundSession() {
|
|
37
|
+
await NativeBackgroundSession.stop();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Reads the current state of the background session.
|
|
41
|
+
*
|
|
42
|
+
* See [Start a background session](#start-a-background-session).
|
|
43
|
+
*
|
|
44
|
+
* @platform android
|
|
45
|
+
*/ export function getBackgroundSessionStatus() {
|
|
46
|
+
return NativeBackgroundSession.status();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=BackgroundSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["next/js/BackgroundSession.ts"],"sourcesContent":[null],"names":["NativeBackgroundSession","ensureBackgroundSessionStarted","options","ensureStarted","stopBackgroundSession","stop","getBackgroundSessionStatus","status"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,YAAY;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,OAAO,eAAeC,+BACpBC,OAAkC;IAElC,MAAMF,wBAAwBG,aAAa,CAACD;AAC9C;AAEA;;;;;;CAMC,GACD,OAAO,eAAeE;IACpB,MAAMJ,wBAAwBK,IAAI;AACpC;AAEA;;;;;;CAMC,GACD,OAAO,SAASC;IACd,OAAON,wBAAwBO,MAAM;AACvC"}
|
|
@@ -1,9 +1,45 @@
|
|
|
1
1
|
import type { SharedRef } from 'expo';
|
|
2
2
|
import type { LocationProviderRefType } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* A location provider is the backend that serves location requests on Android. Each static method
|
|
5
|
+
* returns a provider to pass to `setLocationProvider`. The default tries Google Play services first
|
|
6
|
+
* and falls back to the Android framework, so most apps never need this.
|
|
7
|
+
*
|
|
8
|
+
* @platform android
|
|
9
|
+
*/
|
|
3
10
|
export declare class LocationProvider {
|
|
11
|
+
/**
|
|
12
|
+
* The fused location provider from Google Play services. When Google Play services are absent,
|
|
13
|
+
* location requests that use this provider throw.
|
|
14
|
+
*
|
|
15
|
+
* @platform android
|
|
16
|
+
*/
|
|
4
17
|
static Gms(): SharedRef<LocationProviderRefType>;
|
|
18
|
+
/**
|
|
19
|
+
* The Android framework `LocationManager`, available without Google Play services.
|
|
20
|
+
*
|
|
21
|
+
* @platform android
|
|
22
|
+
*/
|
|
5
23
|
static Android(): SharedRef<LocationProviderRefType>;
|
|
24
|
+
/**
|
|
25
|
+
* Tries the providers in order and uses the first one that can serve the request.
|
|
26
|
+
*
|
|
27
|
+
* @param providers The providers to try, most preferred first.
|
|
28
|
+
* @platform android
|
|
29
|
+
*/
|
|
6
30
|
static Fallback(providers: SharedRef<LocationProviderRefType>[]): SharedRef<LocationProviderRefType>;
|
|
7
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Selects the provider that serves all later location requests.
|
|
34
|
+
*
|
|
35
|
+
* @param provider A provider from `LocationProvider`.
|
|
36
|
+
* @platform android
|
|
37
|
+
*/
|
|
8
38
|
export declare function setLocationProvider(provider: SharedRef<LocationProviderRefType>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the name of the provider currently serving positions: `GMS`, `Android`, or the chain of a
|
|
41
|
+
* fallback, such as the default `Fallback: GMS -> Android`.
|
|
42
|
+
*
|
|
43
|
+
* @platform android
|
|
44
|
+
*/
|
|
9
45
|
export declare function getSelectedLocationProviderName(): string;
|
|
@@ -1,19 +1,49 @@
|
|
|
1
1
|
import { NativeLocationModuleNext, NativeLocationProvider } from '../native';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* A location provider is the backend that serves location requests on Android. Each static method
|
|
4
|
+
* returns a provider to pass to `setLocationProvider`. The default tries Google Play services first
|
|
5
|
+
* and falls back to the Android framework, so most apps never need this.
|
|
6
|
+
*
|
|
7
|
+
* @platform android
|
|
8
|
+
*/ export class LocationProvider {
|
|
9
|
+
/**
|
|
10
|
+
* The fused location provider from Google Play services. When Google Play services are absent,
|
|
11
|
+
* location requests that use this provider throw.
|
|
12
|
+
*
|
|
13
|
+
* @platform android
|
|
14
|
+
*/ static Gms() {
|
|
4
15
|
return NativeLocationProvider.Gms();
|
|
5
16
|
}
|
|
6
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The Android framework `LocationManager`, available without Google Play services.
|
|
19
|
+
*
|
|
20
|
+
* @platform android
|
|
21
|
+
*/ static Android() {
|
|
7
22
|
return NativeLocationProvider.Android();
|
|
8
23
|
}
|
|
9
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Tries the providers in order and uses the first one that can serve the request.
|
|
26
|
+
*
|
|
27
|
+
* @param providers The providers to try, most preferred first.
|
|
28
|
+
* @platform android
|
|
29
|
+
*/ static Fallback(providers) {
|
|
10
30
|
return NativeLocationProvider.Fallback(providers);
|
|
11
31
|
}
|
|
12
32
|
}
|
|
13
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Selects the provider that serves all later location requests.
|
|
35
|
+
*
|
|
36
|
+
* @param provider A provider from `LocationProvider`.
|
|
37
|
+
* @platform android
|
|
38
|
+
*/ export function setLocationProvider(provider) {
|
|
14
39
|
NativeLocationModuleNext.setLocationProvider(provider);
|
|
15
40
|
}
|
|
16
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Gets the name of the provider currently serving positions: `GMS`, `Android`, or the chain of a
|
|
43
|
+
* fallback, such as the default `Fallback: GMS -> Android`.
|
|
44
|
+
*
|
|
45
|
+
* @platform android
|
|
46
|
+
*/ export function getSelectedLocationProviderName() {
|
|
17
47
|
return NativeLocationModuleNext.getSelectedLocationProviderName();
|
|
18
48
|
}
|
|
19
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/LocationProvider.ts"],"sourcesContent":[null],"names":["NativeLocationModuleNext","NativeLocationProvider","LocationProvider","Gms","Android","Fallback","providers","setLocationProvider","provider","getSelectedLocationProviderName"],"mappings":"AAEA,SAASA,wBAAwB,EAAEC,sBAAsB,QAAQ,YAAY;AAG7E,OAAO,MAAMC;IACX,OAAOC,MAA0C;QAC/C,OAAOF,uBAAuBE,GAAG;IACnC;IAEA,OAAOC,UAA8C;QACnD,OAAOH,uBAAuBG,OAAO;IACvC;IAEA,OAAOC,SACLC,SAA+C,EACX;QACpC,OAAOL,uBAAuBI,QAAQ,CAACC;IACzC;AACF;AAEA,OAAO,SAASC,oBAAoBC,QAA4C;IAC9ER,yBAAyBO,mBAAmB,CAACC;AAC/C;AAEA,OAAO,SAASC;IACd,OAAOT,yBAAyBS,+BAA+B;AACjE"}
|
|
1
|
+
{"version":3,"sources":["next/js/LocationProvider.ts"],"sourcesContent":[null],"names":["NativeLocationModuleNext","NativeLocationProvider","LocationProvider","Gms","Android","Fallback","providers","setLocationProvider","provider","getSelectedLocationProviderName"],"mappings":"AAEA,SAASA,wBAAwB,EAAEC,sBAAsB,QAAQ,YAAY;AAG7E;;;;;;CAMC,GACD,OAAO,MAAMC;IACX;;;;;GAKC,GACD,OAAOC,MAA0C;QAC/C,OAAOF,uBAAuBE,GAAG;IACnC;IAEA;;;;GAIC,GACD,OAAOC,UAA8C;QACnD,OAAOH,uBAAuBG,OAAO;IACvC;IAEA;;;;;GAKC,GACD,OAAOC,SACLC,SAA+C,EACX;QACpC,OAAOL,uBAAuBI,QAAQ,CAACC;IACzC;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASC,oBAAoBC,QAA4C;IAC9ER,yBAAyBO,mBAAmB,CAACC;AAC/C;AAEA;;;;;CAKC,GACD,OAAO,SAASC;IACd,OAAOT,yBAAyBS,+BAA+B;AACjE"}
|
|
@@ -1,15 +1,65 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { BackgroundTaskStatus, LocationProfile, LocationTaskOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Starts and stops the delivery of positions to the task defined with `defineLocationTask`.
|
|
4
|
+
* The delivery is registered with the system, so it outlives the JS context: it survives the app
|
|
5
|
+
* moving to the background and, with the background permission, the app being terminated.
|
|
6
|
+
*
|
|
7
|
+
* On Android, positions keep arriving after the app process ended. Requires the background
|
|
8
|
+
* permission. While the app is in the background and no location foreground service is running,
|
|
9
|
+
* Android throttles the delivery. The handle keeps the provider selected during construction; to
|
|
10
|
+
* use a different provider, construct a new handle.
|
|
11
|
+
*
|
|
12
|
+
* On iOS, positions come from `CLLocationUpdate.liveUpdates`. Requires the `location` background
|
|
13
|
+
* mode and the foreground permission.
|
|
14
|
+
*
|
|
15
|
+
* See [Receive positions in the background](#receive-positions-in-the-background).
|
|
16
|
+
*/
|
|
3
17
|
export declare class LocationUpdatesHandle {
|
|
4
18
|
private readonly nativeHandle;
|
|
19
|
+
/**
|
|
20
|
+
* @param taskName The task that receives the positions. Must match the name passed to
|
|
21
|
+
* `defineLocationTask`; both default to the same name.
|
|
22
|
+
*/
|
|
5
23
|
constructor(taskName?: string);
|
|
24
|
+
/**
|
|
25
|
+
* Stages the profile for the next `start()`. It has no effect on a delivery that is already
|
|
26
|
+
* running; call `stop()` and `start()` again to apply it.
|
|
27
|
+
*
|
|
28
|
+
* @return The same handle, for chaining.
|
|
29
|
+
*/
|
|
6
30
|
withProfile(profile: LocationProfile): this;
|
|
31
|
+
/**
|
|
32
|
+
* Registers the delivery with the system and starts sending positions to the task.
|
|
33
|
+
*
|
|
34
|
+
* On Android the promise resolves even when the provider refuses the request for updates.
|
|
35
|
+
*
|
|
36
|
+
* @throws On Android, when the foreground or background permission is not granted, or when
|
|
37
|
+
* `RECEIVE_BOOT_COMPLETED` is missing from the manifest. On iOS, when location services are off
|
|
38
|
+
* or the foreground permission is missing, where the `location` background mode is also required.
|
|
39
|
+
*/
|
|
7
40
|
start(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Unregisters the delivery. Positions stop arriving and the app is no longer relaunched for them.
|
|
43
|
+
*/
|
|
8
44
|
stop(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Checks whether the delivery is registered with the system. It stays registered across app
|
|
47
|
+
* restarts, so check it on launch before calling `start()` again.
|
|
48
|
+
*/
|
|
9
49
|
hasStarted(): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Reads the state of the task. The state lives in the app process, so it resets whenever the
|
|
52
|
+
* process restarts, even while the task stays registered with the system.
|
|
53
|
+
*
|
|
54
|
+
* @platform android
|
|
55
|
+
*/
|
|
56
|
+
status(): BackgroundTaskStatus;
|
|
10
57
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Defines the task that receives the positions started with `LocationUpdatesHandle`.
|
|
60
|
+
* Wraps `TaskManager.defineTask`, so call it in the global scope of a module imported at startup.
|
|
61
|
+
* See [Receive positions in the background](#receive-positions-in-the-background).
|
|
62
|
+
*
|
|
63
|
+
* @param options The task name and the callbacks for positions and errors.
|
|
64
|
+
*/
|
|
65
|
+
export declare function defineLocationTask({ taskName, onPosition, onError, }: LocationTaskOptions): void;
|
|
@@ -1,25 +1,74 @@
|
|
|
1
1
|
import { NativeLocationUpdatesHandle } from '../native';
|
|
2
2
|
const DEFAULT_LOCATION_TASK_NAME = 'expo-location-background-location';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Starts and stops the delivery of positions to the task defined with `defineLocationTask`.
|
|
5
|
+
* The delivery is registered with the system, so it outlives the JS context: it survives the app
|
|
6
|
+
* moving to the background and, with the background permission, the app being terminated.
|
|
7
|
+
*
|
|
8
|
+
* On Android, positions keep arriving after the app process ended. Requires the background
|
|
9
|
+
* permission. While the app is in the background and no location foreground service is running,
|
|
10
|
+
* Android throttles the delivery. The handle keeps the provider selected during construction; to
|
|
11
|
+
* use a different provider, construct a new handle.
|
|
12
|
+
*
|
|
13
|
+
* On iOS, positions come from `CLLocationUpdate.liveUpdates`. Requires the `location` background
|
|
14
|
+
* mode and the foreground permission.
|
|
15
|
+
*
|
|
16
|
+
* See [Receive positions in the background](#receive-positions-in-the-background).
|
|
17
|
+
*/ export class LocationUpdatesHandle {
|
|
4
18
|
nativeHandle;
|
|
5
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @param taskName The task that receives the positions. Must match the name passed to
|
|
21
|
+
* `defineLocationTask`; both default to the same name.
|
|
22
|
+
*/ constructor(taskName = DEFAULT_LOCATION_TASK_NAME){
|
|
6
23
|
this.nativeHandle = new NativeLocationUpdatesHandle(taskName);
|
|
7
24
|
}
|
|
8
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Stages the profile for the next `start()`. It has no effect on a delivery that is already
|
|
27
|
+
* running; call `stop()` and `start()` again to apply it.
|
|
28
|
+
*
|
|
29
|
+
* @return The same handle, for chaining.
|
|
30
|
+
*/ withProfile(profile) {
|
|
9
31
|
this.nativeHandle.withProfile(profile);
|
|
10
32
|
return this;
|
|
11
33
|
}
|
|
12
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Registers the delivery with the system and starts sending positions to the task.
|
|
36
|
+
*
|
|
37
|
+
* On Android the promise resolves even when the provider refuses the request for updates.
|
|
38
|
+
*
|
|
39
|
+
* @throws On Android, when the foreground or background permission is not granted, or when
|
|
40
|
+
* `RECEIVE_BOOT_COMPLETED` is missing from the manifest. On iOS, when location services are off
|
|
41
|
+
* or the foreground permission is missing, where the `location` background mode is also required.
|
|
42
|
+
*/ start() {
|
|
13
43
|
return this.nativeHandle.start();
|
|
14
44
|
}
|
|
15
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Unregisters the delivery. Positions stop arriving and the app is no longer relaunched for them.
|
|
47
|
+
*/ stop() {
|
|
16
48
|
return this.nativeHandle.stop();
|
|
17
49
|
}
|
|
18
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Checks whether the delivery is registered with the system. It stays registered across app
|
|
52
|
+
* restarts, so check it on launch before calling `start()` again.
|
|
53
|
+
*/ hasStarted() {
|
|
19
54
|
return this.nativeHandle.hasStarted();
|
|
20
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Reads the state of the task. The state lives in the app process, so it resets whenever the
|
|
58
|
+
* process restarts, even while the task stays registered with the system.
|
|
59
|
+
*
|
|
60
|
+
* @platform android
|
|
61
|
+
*/ status() {
|
|
62
|
+
return this.nativeHandle.status();
|
|
63
|
+
}
|
|
21
64
|
}
|
|
22
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Defines the task that receives the positions started with `LocationUpdatesHandle`.
|
|
67
|
+
* Wraps `TaskManager.defineTask`, so call it in the global scope of a module imported at startup.
|
|
68
|
+
* See [Receive positions in the background](#receive-positions-in-the-background).
|
|
69
|
+
*
|
|
70
|
+
* @param options The task name and the callbacks for positions and errors.
|
|
71
|
+
*/ export function defineLocationTask({ taskName = DEFAULT_LOCATION_TASK_NAME, onPosition, onError }) {
|
|
23
72
|
requireTaskManager().defineTask(taskName, async ({ data, error })=>{
|
|
24
73
|
if (error) {
|
|
25
74
|
onError?.(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/LocationUpdatesHandle.ts"],"sourcesContent":[null],"names":["NativeLocationUpdatesHandle","DEFAULT_LOCATION_TASK_NAME","LocationUpdatesHandle","nativeHandle","taskName","withProfile","profile","start","stop","hasStarted","defineLocationTask","onPosition","onError","requireTaskManager","defineTask","data","error","require","Error"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["next/js/LocationUpdatesHandle.ts"],"sourcesContent":[null],"names":["NativeLocationUpdatesHandle","DEFAULT_LOCATION_TASK_NAME","LocationUpdatesHandle","nativeHandle","taskName","withProfile","profile","start","stop","hasStarted","status","defineLocationTask","onPosition","onError","requireTaskManager","defineTask","data","error","require","Error"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,YAAY;AASxD,MAAMC,6BAA6B;AAEnC;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMC;IACMC,aAA+C;IAEhE;;;GAGC,GACD,YAAYC,WAAmBH,0BAA0B,CAAE;QACzD,IAAI,CAACE,YAAY,GAAG,IAAIH,4BAA4BI;IACtD;IAEA;;;;;GAKC,GACDC,YAAYC,OAAwB,EAAQ;QAC1C,IAAI,CAACH,YAAY,CAACE,WAAW,CAACC;QAC9B,OAAO,IAAI;IACb;IAEA;;;;;;;;GAQC,GACDC,QAAuB;QACrB,OAAO,IAAI,CAACJ,YAAY,CAACI,KAAK;IAChC;IAEA;;GAEC,GACDC,OAAsB;QACpB,OAAO,IAAI,CAACL,YAAY,CAACK,IAAI;IAC/B;IAEA;;;GAGC,GACDC,aAA+B;QAC7B,OAAO,IAAI,CAACN,YAAY,CAACM,UAAU;IACrC;IAEA;;;;;GAKC,GACDC,SAA+B;QAC7B,OAAO,IAAI,CAACP,YAAY,CAACO,MAAM;IACjC;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,mBAAmB,EACjCP,WAAWH,0BAA0B,EACrCW,UAAU,EACVC,OAAO,EACa;IACpBC,qBAAqBC,UAAU,CAAWX,UAAU,OAAO,EAAEY,IAAI,EAAEC,KAAK,EAAE;QACxE,IAAIA,OAAO;YACTJ,UAAUI;YACV;QACF;QACAL,WAAWI;IACb;AACF;AAEA,SAASF;IACP,IAAI;QACF,OAAOI,QAAQ;IACjB,EAAE,OAAM;QACN,MAAM,IAAIC,MACR;IAEJ;AACF"}
|