moko-permissions icon indicating copy to clipboard operation
moko-permissions copied to clipboard

Multiple permission

Open fjr619 opened this issue 1 year ago • 3 comments

Hi may i get example how to handle multiple permissions with moko? do i need create multiple controller for that too?

fjr619 avatar Jul 01 '24 12:07 fjr619

just call providePermission multiple times

class ViewModel(val permissionsController: PermissionsController): ViewModel() {
    fun onPhotoPressed() {
        viewModelScope.launch {
            try {
                permissionsController.providePermission(Permission.GALLERY)
                permissionsController.providePermission(Permission.CAMERA)
                // Permission has been granted successfully.
            } catch(deniedAlways: DeniedAlwaysException) {
                // Permission is always denied.
            } catch(denied: DeniedException) {
                // Permission was denied.
            }
        }
    }
}

Alex009 avatar Jul 01 '24 14:07 Alex009

@Alex009 Is the same applies if its for location permission?

andiosdev avatar Jul 21 '24 22:07 andiosdev

Yes

Alex009 avatar Jul 22 '24 01:07 Alex009

@Alex009 I am thinking to create an extension fn around this for requesting multiple permissions.

farhazulMullick avatar May 26 '25 17:05 farhazulMullick