iosMain.io.github.kpermissions.handler.permissions.requestMicrophonePermission.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of KPermissions Show documentation
Show all versions of KPermissions Show documentation
Plugin for request permissions android and ios KMM
The newest version!
package io.github.kpermissions.handler.permissions
import platform.AVFAudio.AVAudioSession
import platform.AVFAudio.AVAudioSessionRecordPermissionGranted
import platform.AVFAudio.AVAudioSessionRecordPermissionUndetermined
fun requestMicrophonePermission(onPermissionResult: (Boolean) -> Unit) {
val permissionStatus = AVAudioSession.sharedInstance().recordPermission()
when (permissionStatus) {
AVAudioSessionRecordPermissionGranted -> {
onPermissionResult(true)
}
AVAudioSessionRecordPermissionUndetermined -> {
AVAudioSession.sharedInstance().requestRecordPermission { granted ->
onPermissionResult(granted)
}
}
else -> {
onPermissionResult(false)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy