Permission Requests

Video and audio calls require Android Runtime Permissions to access the camera and microphone. You must request these permissions before calling call.join().

The simplest method to request Android Runtime permissions is by using the LaunchCallPermissions API before invoking the join method. Here's an example of how to do this:

val call = client.call(type = "default", id = callId)
LaunchCallPermissions(call = call) {
    // this lambda function will be executed after all the permissions are granted.
    call.join(create = true)
}

After permissions are granted, the user sees the call lobby:

Call Lobby with permission

If you want to request permissions without using the LaunchCallPermissions API, you can achieve it by using rememberCallPermissionsState seamlessly.

val permissionState = rememberCallPermissionsState(call = call)
val allPermissionGranted = permissionState.allPermissionsGranted

Button(onClick = { permissionState.launchPermissionRequest() }) {
    Text(text = "Request permissions")
}

// Once all permissions are granted, join the call
LaunchedEffect(key1 = allPermissionGranted) {
    if (allPermissionGranted){
        call.join(create = true)
    }
}

Request Multiple Permissions

rememberCallPermissionsState is built with accompanist under the hood, so it also provides similar functions. You can tweak the list of permissions that you want to request by giving the permission parameter.

val permissionState = rememberCallPermissionsState(
    call = call,
    permissions = listOf(
        android.Manifest.permission.CAMERA,
        android.Manifest.permission.RECORD_AUDIO,
        .. // more!
    )
)

You can also handle whether each permission was granted or not like the example below:

val permissionState = rememberCallPermissionsState(
    call = call,
    permissions = listOf(
        android.Manifest.permission.CAMERA,
        android.Manifest.permission.RECORD_AUDIO,
    )
) {
    if (it[android.Manifest.permission.CAMERA] == true) {
        call.camera.setEnabled(true)
    } else {
        // shows a toast or dialog
    }

    if (it[android.Manifest.permission.RECORD_AUDIO] == true) {
        call.microphone.setEnabled(true)
    } else {
        // shows a toast or dialog
    }
}

So you can execute some additional tasks if a user grants permission, or display a toast message or popup dialog if a user denies permissions.

Request a Single Permission

You can also simply request a single permission for a camera and microphone like the example below:

// request a camera permission
val cameraPermissionState = rememberCameraPermissionState(call = call)
cameraPermissionState.launchPermissionRequest()

// request a microphone permission
val microphonePermissionState = rememberMicrophonePermissionState(call = call)
microphonePermissionState.launchPermissionRequest()