diff --git a/geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt b/geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt index 93d5982..cf5f078 100644 --- a/geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt +++ b/geo/src/androidMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt @@ -115,8 +115,12 @@ actual class LocationTracker( } @SuppressLint("MissingPermission") - actual suspend fun startTracking() { - permissionsController.providePermission(Permission.LOCATION) + actual suspend fun startTracking(allowCoarseLocation: Boolean) { + val permission = when { + allowCoarseLocation -> Permission.COARSE_LOCATION + else -> Permission.LOCATION + } + permissionsController.providePermission(permission) // if permissions request failed - execution stops here isStarted = true diff --git a/geo/src/commonMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt b/geo/src/commonMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt index 5415216..57350f1 100644 --- a/geo/src/commonMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt +++ b/geo/src/commonMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt @@ -10,7 +10,9 @@ import kotlinx.coroutines.flow.Flow expect class LocationTracker { val permissionsController: PermissionsController - suspend fun startTracking() // can be suspended for request permission + // can be suspended for request permission + suspend fun startTracking(allowCoarseLocation: Boolean = false) + fun stopTracking() fun getLocationsFlow(): Flow diff --git a/geo/src/iosMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt b/geo/src/iosMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt index 6a5ea6f..5d3ad9a 100644 --- a/geo/src/iosMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt +++ b/geo/src/iosMain/kotlin/dev/icerock/moko/geo/LocationTracker.kt @@ -35,8 +35,12 @@ actual class LocationTracker( desiredAccuracy = accuracy } - actual suspend fun startTracking() { - permissionsController.providePermission(Permission.LOCATION) + actual suspend fun startTracking(allowCoarseLocation: Boolean) { + val permission = when { + allowCoarseLocation -> Permission.COARSE_LOCATION + else -> Permission.LOCATION + } + permissionsController.providePermission(permission) // if permissions request failed - execution stops here locationManager.startUpdatingLocation()