Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Permissions are granted but permission state is NotDetermined or False #100

Open
anox1337 opened this issue Jan 18, 2024 · 0 comments
Open

Comments

@anox1337
Copy link

Hello,

using multiplatform compose.

Requesting permission (via providePermission()) works ✔️ but getPermissionState always returns NotDetermined and isPermissionGranted returns false

I call this code in one of my UIs to ensure bluetooth permissions are set. iOS correctly asks the user to grant permissions. But the controller never seems to register that these have been granted.

`fun RequestBluetoothPermission(executeAfter: () -> Unit) {

val factory: PermissionsControllerFactory = rememberPermissionsControllerFactory()
val controller: PermissionsController = remember(factory) { factory.createPermissionsController() }
val coroutineScope: CoroutineScope = rememberCoroutineScope()

BindEffect(controller)

coroutineScope.launch {
    try {
        Logger.i("Permission state BLUETOOTH_SCAN: ${controller.getPermissionState(Permission.BLUETOOTH_SCAN)}")
        Logger.i("Permission state BLUETOOTH_CONNECT: ${controller.getPermissionState(Permission.BLUETOOTH_CONNECT)}")

        controller.providePermission(Permission.BLUETOOTH_SCAN)
        controller.providePermission(Permission.BLUETOOTH_CONNECT)

        Logger.i("After Permission state BLUETOOTH_SCAN: ${controller.getPermissionState(Permission.BLUETOOTH_SCAN)}")
        Logger.i("After Permission state BLUETOOTH_CONNECT: ${controller.getPermissionState(Permission.BLUETOOTH_CONNECT)}")

        Logger.i("After Permission granted BLUETOOTH_SCAN: ${controller.getPermissionState(Permission.BLUETOOTH_SCAN)}")
        Logger.i("After Permission granted BLUETOOTH_CONNECT: ${controller.getPermissionState(Permission.BLUETOOTH_CONNECT)}")
        
        if (controller.isPermissionGranted(Permission.BLUETOOTH_CONNECT) &&
            controller.isPermissionGranted(Permission.BLUETOOTH_SCAN) ) {
            executeAfter()
        }
    } catch (e: Exception) {
        e.printStackTrace()
        Logger.e(e.message.toString())
    }
}

}
`

btw this works on Android but not on iOS 17. Been testing with an iPhone 13.

Anything that I am missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant