iosMain.io.github.kpermissions.handler.PermissionHandler.ios.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
import io.github.kpermissions.enum.EnumAppPermission
import io.github.kpermissions.handler.permissions.requestAppTrackingPermission
import io.github.kpermissions.handler.permissions.requestBlueToothPermission
import io.github.kpermissions.handler.permissions.requestCalendarPermission
import io.github.kpermissions.handler.permissions.requestCameraPermission
import io.github.kpermissions.handler.permissions.requestContactsPermission
import io.github.kpermissions.handler.permissions.requestGalleryPermission
import io.github.kpermissions.handler.permissions.requestLocationAlwaysPermission
import io.github.kpermissions.handler.permissions.requestLocationPermission
import io.github.kpermissions.handler.permissions.requestLocationWhenInUsePermission
import io.github.kpermissions.handler.permissions.requestMicrophonePermission
import io.github.kpermissions.handler.permissions.requestNotificationPermission
import io.github.kpermissions.handler.permissions.requestPhonePermission
import io.github.kpermissions.handler.permissions.requestPhotoPermission
import io.github.kpermissions.handler.permissions.requestStoragePermission
import io.github.kpermissions.handler.permissions.requestVideoPermission
import platform.Foundation.NSURL
import platform.UIKit.UIApplication
import platform.UIKit.UIApplicationOpenSettingsURLString
actual class PermissionHandler actual constructor() {
actual fun requestPermission(
permission: EnumAppPermission,
onPermissionResult: (Boolean) -> Unit
) {
when (permission) {
EnumAppPermission.CALENDAR_WRITE,
EnumAppPermission.CALENDAR_READ -> requestCalendarPermission(onPermissionResult)
EnumAppPermission.CONTACTS_WRITE,
EnumAppPermission.CONTACTS_READ -> requestContactsPermission(onPermissionResult)
EnumAppPermission.LOCATION -> requestLocationPermission(onPermissionResult)
EnumAppPermission.LOCATION_ALWAYS -> requestLocationAlwaysPermission(onPermissionResult)
EnumAppPermission.LOCATION_WHEN_IN_USE -> requestLocationWhenInUsePermission(
onPermissionResult
)
EnumAppPermission.WRITE_STORAGE,
EnumAppPermission.READ_STORAGE -> requestStoragePermission(onPermissionResult)
EnumAppPermission.PHOTO -> requestPhotoPermission(onPermissionResult)
EnumAppPermission.VIDEO -> requestVideoPermission(onPermissionResult)
EnumAppPermission.GALLERY -> requestGalleryPermission(onPermissionResult)
EnumAppPermission.CAMERA -> requestCameraPermission(onPermissionResult)
EnumAppPermission.MICROPHONE -> requestMicrophonePermission(onPermissionResult)
EnumAppPermission.NOTIFICATION -> requestNotificationPermission(onPermissionResult)
EnumAppPermission.PHONE -> requestPhonePermission(onPermissionResult)
EnumAppPermission.APP_TRACKING_TRANSPARENCY -> requestAppTrackingPermission(
onPermissionResult
)
EnumAppPermission.BLUETOOTH -> requestBlueToothPermission(onPermissionResult)
}
}
actual fun openAppSettings() {
val settingsUrl: NSURL = NSURL.URLWithString(UIApplicationOpenSettingsURLString)!!
UIApplication.sharedApplication.openURL(settingsUrl)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy