expo-location 58.0.15 → 58.0.17
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 +22 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/location/taskConsumers/LocationTaskConsumer.kt +63 -7
- 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 +5 -4
- package/build/next/js/LocationProvider.js +5 -4
- package/build/next/js/LocationProvider.js.map +1 -1
- package/build/next/js/LocationUpdatesHandle.d.ts +17 -5
- package/build/next/js/LocationUpdatesHandle.js +17 -4
- package/build/next/js/LocationUpdatesHandle.js.map +1 -1
- package/build/next/js/Permissions.d.ts +29 -3
- package/build/next/js/Permissions.js +39 -3
- package/build/next/js/Permissions.js.map +1 -1
- package/build/next/js/PositionWatchHandle.d.ts +13 -2
- package/build/next/js/PositionWatchHandle.js +13 -2
- package/build/next/js/PositionWatchHandle.js.map +1 -1
- package/build/next/js/getPosition.d.ts +3 -0
- package/build/next/js/getPosition.js +3 -0
- 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 +1 -0
- package/build/next/js/locationServices.js +1 -0
- 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/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/Position.types.d.ts +30 -10
- package/build/next/types/Position.types.js +11 -8
- package/build/next/types/Position.types.js.map +1 -1
- package/build/next/types/index.d.ts +2 -0
- package/build/next/types/index.js +2 -0
- package/build/next/types/index.js.map +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.15/expo.modules.location-58.0.15-sources.jar → 58.0.17/expo.modules.location-58.0.17-sources.jar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.15/expo.modules.location-58.0.15.aar → 58.0.17/expo.modules.location-58.0.17.aar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.15/expo.modules.location-58.0.15.module → 58.0.17/expo.modules.location-58.0.17.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/{58.0.15/expo.modules.location-58.0.15.pom → 58.0.17/expo.modules.location-58.0.17.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.17/expo.modules.location-58.0.17.pom.sha512 +1 -0
- package/package.json +5 -5
- package/src/next/Location.ts +5 -0
- package/src/next/index.ts +5 -0
- package/src/next/js/BackgroundSession.ts +56 -0
- package/src/next/js/LocationProvider.ts +5 -4
- package/src/next/js/LocationUpdatesHandle.ts +25 -5
- package/src/next/js/Permissions.ts +48 -3
- package/src/next/js/PositionWatchHandle.ts +13 -2
- package/src/next/js/getPosition.ts +3 -0
- package/src/next/js/index.ts +8 -0
- package/src/next/js/locationServices.ts +1 -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/LocationUpdates.types.ts +18 -0
- package/src/next/types/Position.types.ts +30 -10
- package/src/next/types/index.ts +2 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.location/58.0.15/expo.modules.location-58.0.15.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [Android] Fix LocationTaskConsumer.didReceiveBroadcast crashing when the user revoked permissions and the task consumer tried getting the lastLocation. ([#51689](https://github.com/expo/expo/pull/51689) by [@HubertBer](https://github.com/HubertBer))
|
|
8
|
+
|
|
9
|
+
## 58.0.16
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [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))
|
|
14
|
+
- [Android] Add the TypeScript interface for the location foreground service: `ensureBackgroundSessionStarted`, `stopBackgroundSession` and `getBackgroundSessionStatus`.
|
|
15
|
+
|
|
16
|
+
Add `getNotificationPermissions`, `requestNotificationPermissions` and the `useNotificationPermissions` hook for the service's notification.
|
|
17
|
+
|
|
18
|
+
Add `LocationUpdatesHandle.status()`, and the `canDeliverUpdates` and `areUpdatesAllowed` fields on `PositionWatchStatus`.
|
|
19
|
+
|
|
20
|
+
([#51320](https://github.com/expo/expo/pull/51320) by [@HubertBer](https://github.com/HubertBer))
|
|
21
|
+
|
|
22
|
+
- Updated dependencies.
|
|
23
|
+
- @expo/image-utils@0.12.5
|
|
24
|
+
|
|
3
25
|
## 58.0.15
|
|
4
26
|
|
|
5
27
|
### 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.17'
|
|
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.17"
|
|
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
|
|
@@ -85,9 +89,13 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
85
89
|
handleLocationUpdate(result.locations)
|
|
86
90
|
} else {
|
|
87
91
|
try {
|
|
88
|
-
mLocationClient.lastLocation
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
mLocationClient.lastLocation
|
|
93
|
+
.addOnSuccessListener { location: Location? ->
|
|
94
|
+
location?.let { handleLocationUpdate(listOf(it)) }
|
|
95
|
+
}
|
|
96
|
+
.addOnFailureListener {
|
|
97
|
+
Log.e(TAG, "Cannot get last location: " + it.message)
|
|
98
|
+
}
|
|
91
99
|
} catch (e: SecurityException) {
|
|
92
100
|
Log.e(TAG, "Cannot get last location: " + e.message)
|
|
93
101
|
}
|
|
@@ -204,6 +212,11 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
204
212
|
|
|
205
213
|
// Foreground service is requested but not running.
|
|
206
214
|
if (mService == null) {
|
|
215
|
+
// Android 14+ throws without a location permission, which can expire while the task stays registered.
|
|
216
|
+
if (!hasLocationPermission()) {
|
|
217
|
+
Log.w(TAG, "Foreground location task cannot be started without a location permission")
|
|
218
|
+
return
|
|
219
|
+
}
|
|
207
220
|
val serviceIntent = Intent(context, LocationTaskService::class.java)
|
|
208
221
|
val extras = Bundle()
|
|
209
222
|
val serviceOptions = options.getArguments(FOREGROUND_SERVICE_KEY).toBundle()
|
|
@@ -213,7 +226,15 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
213
226
|
extras.putString("taskName", task.name)
|
|
214
227
|
extras.putBoolean("killService", serviceOptions.getBoolean("killServiceOnDestroy", false))
|
|
215
228
|
serviceIntent.putExtras(extras)
|
|
216
|
-
|
|
229
|
+
try {
|
|
230
|
+
context.startForegroundService(serviceIntent)
|
|
231
|
+
} catch (e: RuntimeException) {
|
|
232
|
+
if (!isStartRejected(e)) {
|
|
233
|
+
throw e
|
|
234
|
+
}
|
|
235
|
+
Log.w(TAG, "Foreground location task could not be started", e)
|
|
236
|
+
return
|
|
237
|
+
}
|
|
217
238
|
context.bindService(
|
|
218
239
|
serviceIntent,
|
|
219
240
|
object : ServiceConnection {
|
|
@@ -221,7 +242,16 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
221
242
|
mService = (service as? ServiceBinder)?.service
|
|
222
243
|
mService?.let {
|
|
223
244
|
it.setParentContext(context)
|
|
224
|
-
|
|
245
|
+
try {
|
|
246
|
+
it.startForeground(serviceOptions)
|
|
247
|
+
} catch (e: RuntimeException) {
|
|
248
|
+
if (!isStartRejected(e)) {
|
|
249
|
+
throw e
|
|
250
|
+
}
|
|
251
|
+
Log.w(TAG, "Foreground location task could not enter the foreground", e)
|
|
252
|
+
releaseService()
|
|
253
|
+
return
|
|
254
|
+
}
|
|
225
255
|
// The task was unregistered while this bind was pending: didUnregister() found no
|
|
226
256
|
// service to stop. Stop it now. startForeground() above is still required, since the
|
|
227
257
|
// service was started with startForegroundService().
|
|
@@ -235,12 +265,38 @@ class LocationTaskConsumer(context: Context, taskManagerUtils: TaskManagerUtilsI
|
|
|
235
265
|
mService?.stop()
|
|
236
266
|
mService = null
|
|
237
267
|
}
|
|
238
|
-
},
|
|
268
|
+
}.also { mServiceConnection = it },
|
|
239
269
|
Context.BIND_AUTO_CREATE
|
|
240
270
|
)
|
|
241
271
|
} else {
|
|
242
272
|
// Restart the service with new service options.
|
|
243
|
-
|
|
273
|
+
try {
|
|
274
|
+
mService?.startForeground(options.getArguments(FOREGROUND_SERVICE_KEY).toBundle())
|
|
275
|
+
} catch (e: RuntimeException) {
|
|
276
|
+
if (!isStartRejected(e)) {
|
|
277
|
+
throw e
|
|
278
|
+
}
|
|
279
|
+
Log.w(TAG, "Foreground location task could not be restarted", e)
|
|
280
|
+
releaseService()
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// ForegroundServiceStartNotAllowedException and BackgroundServiceStartNotAllowedException are IllegalStateExceptions.
|
|
286
|
+
private fun isStartRejected(e: RuntimeException): Boolean {
|
|
287
|
+
return e is SecurityException || e is IllegalStateException
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private fun releaseService() {
|
|
291
|
+
mService?.stop()
|
|
292
|
+
mService = null
|
|
293
|
+
mServiceConnection?.let { context.unbindService(it) }
|
|
294
|
+
mServiceConnection = null
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
private fun hasLocationPermission(): Boolean {
|
|
298
|
+
return listOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION).any {
|
|
299
|
+
ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED
|
|
244
300
|
}
|
|
245
301
|
}
|
|
246
302
|
|
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 LocationTaskOptions, 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,15 +1,16 @@
|
|
|
1
1
|
import type { SharedRef } from 'expo';
|
|
2
2
|
import type { LocationProviderRefType } from '../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
7
|
*
|
|
8
8
|
* @platform android
|
|
9
9
|
*/
|
|
10
10
|
export declare class LocationProvider {
|
|
11
11
|
/**
|
|
12
|
-
* The fused location provider from Google Play services.
|
|
12
|
+
* The fused location provider from Google Play services. When Google Play services are absent,
|
|
13
|
+
* location requests that use this provider throw.
|
|
13
14
|
*
|
|
14
15
|
* @platform android
|
|
15
16
|
*/
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { NativeLocationModuleNext, NativeLocationProvider } from '../native';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
6
|
*
|
|
7
7
|
* @platform android
|
|
8
8
|
*/ export class LocationProvider {
|
|
9
9
|
/**
|
|
10
|
-
* The fused location provider from Google Play services.
|
|
10
|
+
* The fused location provider from Google Play services. When Google Play services are absent,
|
|
11
|
+
* location requests that use this provider throw.
|
|
11
12
|
*
|
|
12
13
|
* @platform android
|
|
13
14
|
*/ static Gms() {
|
|
@@ -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;;;;;;CAMC,GACD,OAAO,MAAMC;IACX
|
|
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,11 +1,13 @@
|
|
|
1
|
-
import type { LocationProfile, LocationTaskOptions } from '../types';
|
|
1
|
+
import type { BackgroundTaskStatus, LocationProfile, LocationTaskOptions } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Starts and stops the delivery of positions to the task defined with `defineLocationTask`.
|
|
4
4
|
* The delivery is registered with the system, so it outlives the JS context: it survives the app
|
|
5
5
|
* moving to the background and, with the background permission, the app being terminated.
|
|
6
6
|
*
|
|
7
7
|
* On Android, positions keep arriving after the app process ended. Requires the background
|
|
8
|
-
* permission.
|
|
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.
|
|
9
11
|
*
|
|
10
12
|
* On iOS, positions come from `CLLocationUpdate.liveUpdates`. Requires the `location` background
|
|
11
13
|
* mode and the foreground permission.
|
|
@@ -28,9 +30,12 @@ export declare class LocationUpdatesHandle {
|
|
|
28
30
|
withProfile(profile: LocationProfile): this;
|
|
29
31
|
/**
|
|
30
32
|
* Registers the delivery with the system and starts sending positions to the task.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
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.
|
|
34
39
|
*/
|
|
35
40
|
start(): Promise<void>;
|
|
36
41
|
/**
|
|
@@ -42,6 +47,13 @@ export declare class LocationUpdatesHandle {
|
|
|
42
47
|
* restarts, so check it on launch before calling `start()` again.
|
|
43
48
|
*/
|
|
44
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;
|
|
45
57
|
}
|
|
46
58
|
/**
|
|
47
59
|
* Defines the task that receives the positions started with `LocationUpdatesHandle`.
|
|
@@ -6,7 +6,9 @@ const DEFAULT_LOCATION_TASK_NAME = 'expo-location-background-location';
|
|
|
6
6
|
* moving to the background and, with the background permission, the app being terminated.
|
|
7
7
|
*
|
|
8
8
|
* On Android, positions keep arriving after the app process ended. Requires the background
|
|
9
|
-
* permission.
|
|
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.
|
|
10
12
|
*
|
|
11
13
|
* On iOS, positions come from `CLLocationUpdate.liveUpdates`. Requires the `location` background
|
|
12
14
|
* mode and the foreground permission.
|
|
@@ -31,9 +33,12 @@ const DEFAULT_LOCATION_TASK_NAME = 'expo-location-background-location';
|
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Registers the delivery with the system and starts sending positions to the task.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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.
|
|
37
42
|
*/ start() {
|
|
38
43
|
return this.nativeHandle.start();
|
|
39
44
|
}
|
|
@@ -48,6 +53,14 @@ const DEFAULT_LOCATION_TASK_NAME = 'expo-location-background-location';
|
|
|
48
53
|
*/ hasStarted() {
|
|
49
54
|
return this.nativeHandle.hasStarted();
|
|
50
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
|
+
}
|
|
51
64
|
}
|
|
52
65
|
/**
|
|
53
66
|
* Defines the task that receives the positions started with `LocationUpdatesHandle`.
|
|
@@ -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":"AAAA,SAASA,2BAA2B,QAAQ,YAAY;
|
|
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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PermissionResponse } from 'expo';
|
|
1
2
|
import type { LocationPermissionResponse, RequestPermissionsOptions } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Checks the foreground location permission without asking the user.
|
|
@@ -22,13 +23,15 @@ export declare function requestForegroundPermissions(options?: RequestPermission
|
|
|
22
23
|
* Checks the background location permission without asking the user.
|
|
23
24
|
*
|
|
24
25
|
* @return A promise that resolves to the current permission. `scope` is `always` when it is
|
|
25
|
-
* granted.
|
|
26
|
+
* granted. `granted` is true only when the foreground permission is granted as well, while
|
|
27
|
+
* `status` reflects the background permission alone.
|
|
26
28
|
*/
|
|
27
29
|
export declare function getBackgroundPermissions(): Promise<LocationPermissionResponse>;
|
|
28
30
|
/**
|
|
29
31
|
* Asks the user for permission to read the location while the app is in the background.
|
|
30
|
-
* On Android, it
|
|
31
|
-
* **Keep Only While Using** resolves with
|
|
32
|
+
* On Android, it throws when `ACCESS_BACKGROUND_LOCATION` is missing from the manifest or the
|
|
33
|
+
* foreground permission is not granted. On iOS, answering **Keep Only While Using** resolves with
|
|
34
|
+
* `status` `denied` and `scope` `whenInUse`.
|
|
32
35
|
*
|
|
33
36
|
* See [Request the background permission](#request-the-background-permission).
|
|
34
37
|
*
|
|
@@ -36,6 +39,24 @@ export declare function getBackgroundPermissions(): Promise<LocationPermissionRe
|
|
|
36
39
|
* @return A promise that resolves to the permission after the user answered.
|
|
37
40
|
*/
|
|
38
41
|
export declare function requestBackgroundPermissions(options?: RequestPermissionsOptions): Promise<LocationPermissionResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Checks the user's permission for posting notifications.
|
|
44
|
+
* See [Start a background session](#start-a-background-session).
|
|
45
|
+
*
|
|
46
|
+
* @return A promise that fulfills with an object of type `PermissionResponse`.
|
|
47
|
+
* @platform android
|
|
48
|
+
*/
|
|
49
|
+
export declare function getNotificationPermissions(): Promise<PermissionResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Asks the user to grant the permission for posting notifications. On Android 12 and lower, no
|
|
52
|
+
* dialog appears, and the result reports whether notifications are on for the app.
|
|
53
|
+
*
|
|
54
|
+
* See [Start a background session](#start-a-background-session).
|
|
55
|
+
*
|
|
56
|
+
* @return A promise that fulfills with an object of type `PermissionResponse`.
|
|
57
|
+
* @platform android
|
|
58
|
+
*/
|
|
59
|
+
export declare function requestNotificationPermissions(): Promise<PermissionResponse>;
|
|
39
60
|
/**
|
|
40
61
|
* Checks or requests the foreground location permission from a component.
|
|
41
62
|
* See [Request the precise location](#request-the-precise-location).
|
|
@@ -68,3 +89,8 @@ export declare const useForegroundLocationPermissions: (options?: import("expo-m
|
|
|
68
89
|
* ```
|
|
69
90
|
*/
|
|
70
91
|
export declare const useBackgroundLocationPermissions: (options?: import("expo-modules-core").PermissionHookOptions<RequestPermissionsOptions> | undefined) => [LocationPermissionResponse | null, () => Promise<LocationPermissionResponse>, () => Promise<LocationPermissionResponse>];
|
|
92
|
+
/**
|
|
93
|
+
* Checks or requests the permission for posting notifications.
|
|
94
|
+
* @platform android
|
|
95
|
+
*/
|
|
96
|
+
export declare const useNotificationPermissions: (options?: import("expo-modules-core").PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Platform, UnavailabilityError } from 'expo';
|
|
1
2
|
import { createPermissionHook } from 'expo-modules-core';
|
|
2
3
|
import { NativeLocationModuleNext } from '../native';
|
|
3
4
|
/**
|
|
@@ -25,14 +26,16 @@ import { NativeLocationModuleNext } from '../native';
|
|
|
25
26
|
* Checks the background location permission without asking the user.
|
|
26
27
|
*
|
|
27
28
|
* @return A promise that resolves to the current permission. `scope` is `always` when it is
|
|
28
|
-
* granted.
|
|
29
|
+
* granted. `granted` is true only when the foreground permission is granted as well, while
|
|
30
|
+
* `status` reflects the background permission alone.
|
|
29
31
|
*/ export async function getBackgroundPermissions() {
|
|
30
32
|
return NativeLocationModuleNext.getBackgroundPermissions();
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Asks the user for permission to read the location while the app is in the background.
|
|
34
|
-
* On Android, it
|
|
35
|
-
* **Keep Only While Using** resolves with
|
|
36
|
+
* On Android, it throws when `ACCESS_BACKGROUND_LOCATION` is missing from the manifest or the
|
|
37
|
+
* foreground permission is not granted. On iOS, answering **Keep Only While Using** resolves with
|
|
38
|
+
* `status` `denied` and `scope` `whenInUse`.
|
|
36
39
|
*
|
|
37
40
|
* See [Request the background permission](#request-the-background-permission).
|
|
38
41
|
*
|
|
@@ -41,6 +44,32 @@ import { NativeLocationModuleNext } from '../native';
|
|
|
41
44
|
*/ export async function requestBackgroundPermissions(options) {
|
|
42
45
|
return NativeLocationModuleNext.requestBackgroundPermissions(options);
|
|
43
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Checks the user's permission for posting notifications.
|
|
49
|
+
* See [Start a background session](#start-a-background-session).
|
|
50
|
+
*
|
|
51
|
+
* @return A promise that fulfills with an object of type `PermissionResponse`.
|
|
52
|
+
* @platform android
|
|
53
|
+
*/ export async function getNotificationPermissions() {
|
|
54
|
+
if (Platform.OS !== 'android') {
|
|
55
|
+
throw new UnavailabilityError('expo-location', 'getNotificationPermissions');
|
|
56
|
+
}
|
|
57
|
+
return NativeLocationModuleNext.getNotificationPermissions();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Asks the user to grant the permission for posting notifications. On Android 12 and lower, no
|
|
61
|
+
* dialog appears, and the result reports whether notifications are on for the app.
|
|
62
|
+
*
|
|
63
|
+
* See [Start a background session](#start-a-background-session).
|
|
64
|
+
*
|
|
65
|
+
* @return A promise that fulfills with an object of type `PermissionResponse`.
|
|
66
|
+
* @platform android
|
|
67
|
+
*/ export async function requestNotificationPermissions() {
|
|
68
|
+
if (Platform.OS !== 'android') {
|
|
69
|
+
throw new UnavailabilityError('expo-location', 'requestNotificationPermissions');
|
|
70
|
+
}
|
|
71
|
+
return NativeLocationModuleNext.requestNotificationPermissions();
|
|
72
|
+
}
|
|
44
73
|
/**
|
|
45
74
|
* Checks or requests the foreground location permission from a component.
|
|
46
75
|
* See [Request the precise location](#request-the-precise-location).
|
|
@@ -77,5 +106,12 @@ import { NativeLocationModuleNext } from '../native';
|
|
|
77
106
|
getMethod: getBackgroundPermissions,
|
|
78
107
|
requestMethod: requestBackgroundPermissions
|
|
79
108
|
});
|
|
109
|
+
/**
|
|
110
|
+
* Checks or requests the permission for posting notifications.
|
|
111
|
+
* @platform android
|
|
112
|
+
*/ export const useNotificationPermissions = createPermissionHook({
|
|
113
|
+
getMethod: getNotificationPermissions,
|
|
114
|
+
requestMethod: requestNotificationPermissions
|
|
115
|
+
});
|
|
80
116
|
|
|
81
117
|
//# sourceMappingURL=Permissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["next/js/Permissions.ts"],"sourcesContent":[null],"names":["createPermissionHook","NativeLocationModuleNext","getForegroundPermissions","requestForegroundPermissions","options","getBackgroundPermissions","requestBackgroundPermissions","useForegroundLocationPermissions","getMethod","requestMethod","useBackgroundLocationPermissions"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,oBAAoB;AAEzD,SAASC,wBAAwB,QAAQ,YAAY;AAGrD;;;;CAIC,GACD,OAAO,eAAeC;IACpB,OAAOD,yBAAyBC,wBAAwB;AAC1D;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC,6BACpBC,OAAmC;IAEnC,OAAOH,yBAAyBE,4BAA4B,CAACC;AAC/D;AAEA
|
|
1
|
+
{"version":3,"sources":["next/js/Permissions.ts"],"sourcesContent":[null],"names":["Platform","UnavailabilityError","createPermissionHook","NativeLocationModuleNext","getForegroundPermissions","requestForegroundPermissions","options","getBackgroundPermissions","requestBackgroundPermissions","getNotificationPermissions","OS","requestNotificationPermissions","useForegroundLocationPermissions","getMethod","requestMethod","useBackgroundLocationPermissions","useNotificationPermissions"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,mBAAmB,QAAQ,OAAO;AAErD,SAASC,oBAAoB,QAAQ,oBAAoB;AAEzD,SAASC,wBAAwB,QAAQ,YAAY;AAGrD;;;;CAIC,GACD,OAAO,eAAeC;IACpB,OAAOD,yBAAyBC,wBAAwB;AAC1D;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC,6BACpBC,OAAmC;IAEnC,OAAOH,yBAAyBE,4BAA4B,CAACC;AAC/D;AAEA;;;;;;CAMC,GACD,OAAO,eAAeC;IACpB,OAAOJ,yBAAyBI,wBAAwB;AAC1D;AAEA;;;;;;;;;;CAUC,GACD,OAAO,eAAeC,6BACpBF,OAAmC;IAEnC,OAAOH,yBAAyBK,4BAA4B,CAACF;AAC/D;AAEA;;;;;;CAMC,GACD,OAAO,eAAeG;IACpB,IAAIT,SAASU,EAAE,KAAK,WAAW;QAC7B,MAAM,IAAIT,oBAAoB,iBAAiB;IACjD;IAEA,OAAOE,yBAAyBM,0BAA0B;AAC5D;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeE;IACpB,IAAIX,SAASU,EAAE,KAAK,WAAW;QAC7B,MAAM,IAAIT,oBAAoB,iBAAiB;IACjD;IAEA,OAAOE,yBAAyBQ,8BAA8B;AAChE;AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,mCAAmCV,qBAAqB;IACnEW,WAAWT;IACXU,eAAeT;AACjB,GAAG;AAEH;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMU,mCAAmCb,qBAAqB;IACnEW,WAAWN;IACXO,eAAeN;AACjB,GAAG;AAEH;;;CAGC,GACD,OAAO,MAAMQ,6BAA6Bd,qBAAqB;IAC7DW,WAAWJ;IACXK,eAAeH;AACjB,GAAG"}
|