File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
androidMain/kotlin/dev/icerock/moko/geo
commonMain/kotlin/dev/icerock/moko/geo
iosMain/kotlin/dev/icerock/moko/geo Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -115,8 +115,12 @@ actual class LocationTracker(
115115 }
116116
117117 @SuppressLint(" MissingPermission" )
118- actual suspend fun startTracking () {
119- permissionsController.providePermission(Permission .LOCATION )
118+ actual suspend fun startTracking (allowCoarseLocation : Boolean ) {
119+ val permission = when {
120+ allowCoarseLocation -> Permission .COARSE_LOCATION
121+ else -> Permission .LOCATION
122+ }
123+ permissionsController.providePermission(permission)
120124 // if permissions request failed - execution stops here
121125
122126 isStarted = true
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ import kotlinx.coroutines.flow.Flow
1010expect class LocationTracker {
1111 val permissionsController: PermissionsController
1212
13- suspend fun startTracking () // can be suspended for request permission
13+ // can be suspended for request permission
14+ suspend fun startTracking (allowCoarseLocation : Boolean = false)
15+
1416 fun stopTracking ()
1517
1618 fun getLocationsFlow (): Flow <LatLng >
Original file line number Diff line number Diff line change @@ -35,8 +35,12 @@ actual class LocationTracker(
3535 desiredAccuracy = accuracy
3636 }
3737
38- actual suspend fun startTracking () {
39- permissionsController.providePermission(Permission .LOCATION )
38+ actual suspend fun startTracking (allowCoarseLocation : Boolean ) {
39+ val permission = when {
40+ allowCoarseLocation -> Permission .COARSE_LOCATION
41+ else -> Permission .LOCATION
42+ }
43+ permissionsController.providePermission(permission)
4044 // if permissions request failed - execution stops here
4145
4246 locationManager.startUpdatingLocation()
You can’t perform that action at this time.
0 commit comments