DownloadPermissionHandler

constructor(permissionState: PermissionState, context: Context, onPermissionRequired: () -> Unit = { if (!context.wasPermissionRequested(permissionState.permission) || permissionState.status.shouldShowRationale) { permissionState.launchPermissionRequest() } else { context.openSystemSettings() } }, onPermissionGranted: (Map<String, Any>) -> Unit = { payload -> (payload[PayloadAttachment] as? Attachment)?.let { ChatClient .instance() .downloadAttachment(context, it) .enqueue() } })

Parameters

permissionState

The permissionState for the permission we need. This should be Manifest.permission.WRITE_EXTERNAL_STORAGE.

context

The context for executing actions.

onPermissionRequired

Handler when the user wants to download a file but the permission has not been granted. By default it will prompt the user for the permission or take him directly to settings.

onPermissionGranted

Handler when the user grants the permission. By default will download the requested file.