GrantGroupHandler

class GrantGroupHandler(grantManager: GrantManager, grants: List<GrantPermission>, scope: CoroutineScope, eventListener: GrantEventListener? = null)

A specialized handler for managing multiple permissions as a single logical group.

Use this when a feature requires several unrelated permissions to be granted simultaneously (e.g., an Augmented Reality feature requiring Camera + Location).

Behavior

  1. Initial Batch: Requests all denied permissions at once to minimize dialogs.

  2. Sequential Cleanup: If some are denied, it iterates through them sequentially to show specific rationale or settings guidance for each.

  3. Success: The onAllGranted callback is only executed when every permission in the group is either GrantStatus.GRANTED or GrantStatus.PARTIAL_GRANTED.

Usage Example

val arGrants = GrantGroupHandler(
grantManager = grantManager,
grants = listOf(AppGrant.CAMERA, AppGrant.LOCATION),
scope = viewModelScope
)

arGrants.request(
rationaleMessages = mapOf(
AppGrant.CAMERA to "Camera is needed to render AR content",
AppGrant.LOCATION to "Location is needed to anchor AR objects"
)
) {
// This block runs ONLY when BOTH permissions are granted
launchArFeature()
}

Constructors

Link copied to clipboard
constructor(grantManager: GrantManager, grants: List<GrantPermission>, scope: CoroutineScope, eventListener: GrantEventListener? = null)

Properties

Link copied to clipboard
val state: StateFlow<GrantGroupUiState>

Observable state for driving group-based permission UI.

Link copied to clipboard

The latest native status for each managed permission in the group.

Functions

Link copied to clipboard
fun onDismiss()

Dismisses the current dialog and cancels the group permission request flow.

Link copied to clipboard

Confirms the rationale for the GrantGroupUiState.currentGrant and requests that specific permission again.

Link copied to clipboard

Confirms the settings guide and opens the app's settings page.

Link copied to clipboard

Re-queries the OS for the status of all permissions in the group.

Link copied to clipboard
fun request(rationaleMessages: Map<GrantPermission, String> = emptyMap(), settingsMessages: Map<GrantPermission, String> = emptyMap(), onAllGranted: () -> Unit)

Initiates the group permission request flow.