[Permissions] Pass PermissionStatus instead of boolean to onPermissionResult
Digipom opened this issue · 6 comments
Description
Please pass in PermissionStatus to onPermissionResult instead of a boolean.
Steps to reproduce
Observe onPermissionResults signature.
Expected behavior
Receiving a PermissionStatus allows us to check the rationale.
Additional context
When the user says "Don't ask again", onPermissionResult is called with granted = false, and shouldShowRationale will also return false.
Example code:
var permissionDeniedFlag: Boolean by remember { mutableStateOf(false) }
val state = rememberPermissionState(
permission = MEDIA_STORAGE_PERMISSION,
onPermissionResult = { granted ->
if (granted) {
// Handle permission granted...
onPermissionGranted()
} else {
// Handle permission denied. Having the status in the callback would avoid having to use a launched effect here.
permissionDeniedFlag = true
}
}
)
if (permissionDeniedFlag && !state.status.shouldShowRationale) {
val context = LocalContext.current
// Automatic denial without rationale means the user selected "don't ask again"
LaunchedEffect(Unit) {
try {
context.openSystemSettingsScreenForApp()
permissionDeniedFlag = false
} catch (e: Exception) {
// Handle exception
onCouldNotOpenSystemSettings()
}
}
}
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Bump to remove stale status
We aren't making changes to the API right now, but I will keep this open for if we do consider making changes in the future because it is a good point
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Bumping to remove stale status
@bentrengrove the bot closed the issue. Is the team still not considering this or could the API be extended in the future? Thank you.