You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing a Kotlin Multiplatform project with native Google Maps integration. The location permission request works perfectly on Android but has issues on iOS.
Devices tested:
iPhone 15 Pro (iOS 17)
iPhone 12 (iOS 17)
Issue:
When the location permission is requested on iOS in viewDidLoad of MapsViewController, the permission dialog is displayed: even if permission is granted by the user, the onSuccess() event is not dispatched during the first attempt. If the MapsViewController is reopened, permission is already granted, and onSuccess() is correctly triggered.
It seems that permissionsController.providePermission(permission) is being called in the PermissionViewModel without any exceptions, but eventsDispatcher.dispatchEvent { onSuccess() } is not executed.
Expected behavior:
When the permission is granted, onSuccess() should be dispatched immediately during the first open of the MapsViewController.
Current behavior:
onSuccess() is only dispatched on subsequent opens of the MapsViewController, after permissions have already been granted.
Logs:
First open:
D/MapsViewController: viewDidLoad
D/MapsViewModel: requestPermission called
D/MapsViewModel: pre provide NotDetermined
Second open:
D/MapsViewController: viewDidLoad
D/MapsViewModel: requestPermission called
D/MapsViewModel: pre provide Granted
D/MapsViewController: Maps permissions granted
D/MapsViewController: setupMapView called
D/MapsViewModel: post provide Granted
Relevant Code:
PermissionViewModel:
classPermissionViewModel(
overridevaleventsDispatcher:EventsDispatcher<EventListener>,
valpermissionsController:PermissionsController,
privatevalpermissionType:Permission
) : ViewModel(), EventsDispatcherOwner<PermissionViewModel.EventListener> {
val permissionState =MutableStateFlow(PermissionState.NotDetermined)
init {
viewModelScope.launch {
permissionState.update { permissionsController.getPermissionState(permissionType) }
println(permissionState)
}
}
funonRequestPermission() {
requestPermission(permissionType)
}
privatefunrequestPermission(permission:Permission) {
LogHelper().logDebug("requestPermission called", "PermissionViewModel")
viewModelScope.launch {
try {
permissionsController.getPermissionState(permission)
.also {
LogHelper().logDebug("pre provide $it", "PermissionViewModel")
}
// Calls suspend function in a coroutine to request some permission.
permissionsController.providePermission(permission)
// If there are no exceptions, permission has been granted successfully.
eventsDispatcher.dispatchEvent { onSuccess() }
} catch (deniedAlwaysException:DeniedAlwaysException) {
eventsDispatcher.dispatchEvent { onDeniedAlways(deniedAlwaysException) }
} catch (deniedException:DeniedException) {
eventsDispatcher.dispatchEvent { onDenied(deniedException) }
} finally {
permissionState.update {
permissionsController.getPermissionState(permission)
.also {
LogHelper().logDebug("post provide $it", "PermissionViewModel")
}
}
}
}
}
interfaceEventListener {
funonSuccess()
funonDenied(exception:DeniedException)
funonDeniedAlways(exception:DeniedAlwaysException)
}
}
Same thing here. Seems to be an internal crash or stalling of the library - cause the app is not proceeding after providePermission() call the first time. Checked the coroutine that's launching the flow - it's running normally and is not being killed.
Hi,
I'm developing a Kotlin Multiplatform project with native Google Maps integration. The location permission request works perfectly on Android but has issues on iOS.
Devices tested:
Issue:
When the location permission is requested on iOS in
viewDidLoad
ofMapsViewController
, the permission dialog is displayed: even if permission is granted by the user, theonSuccess()
event is not dispatched during the first attempt. If theMapsViewController
is reopened, permission is already granted, andonSuccess()
is correctly triggered.It seems that
permissionsController.providePermission(permission)
is being called in thePermissionViewModel
without any exceptions, buteventsDispatcher.dispatchEvent { onSuccess() }
is not executed.Expected behavior:
onSuccess()
should be dispatched immediately during the first open of theMapsViewController
.Current behavior:
onSuccess()
is only dispatched on subsequent opens of theMapsViewController
, after permissions have already been granted.Logs:
Relevant Code:
PermissionViewModel:
MapsViewController:
PermissionHandler:
Could you please help identify why
onSuccess()
is not dispatched on the first attempt?Thank you!
The text was updated successfully, but these errors were encountered: