Skip to main content

Customize permission request handling

The Chat UI SDK channel screen provides features such as sending images, voice messages, files, and initiating calls. When calling APIs that involve sensitive permissions, ChatUI requests permissions from the user and continues execution only after the permission request is granted.

ChatUI does not expose UI related to permission requests. If your application needs to customize the permission request UI, you can intercept ChatUI's permission requests. For example, your application can display a custom screen that explains the purpose of the sensitive permission when ChatUI requests it, meeting compliance requirements for app store submission.

Intercept permission requests

Before entering the channel screen, use the [setRequestPermissionListListener] method of [PermissionCheckUtil] to handle permission requests in the onRequestPermissionList callback.

After processing the permission, notify ChatUI of the permission request result through [IPermissionEventCallback]. confirmed indicates the permission was granted, and cancelled indicates the permission was denied.

Java
PermissionCheckUtil.setRequestPermissionListListener(
new PermissionCheckUtil.IRequestPermissionListListener() {
@Override
public void onRequestPermissionList(
Context activity,
List<String> permissionsNotGranted,
PermissionCheckUtil.IPermissionEventCallback callback) {
AlertDialog dialog =
new AlertDialog.Builder(
activity,
android.R
.style
.Theme_DeviceDefault_Light_Dialog_Alert)
.setMessage("Explain the permission request to the user")
.setPositiveButton(
"Request",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog, int which) {
dialog.dismiss();
callback.confirmed();
}
})
.setNegativeButton(
"Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog, int which) {
dialog.dismiss();
callback.cancelled();
}
})
.show();
}
});

See also

  • To describe the purpose of sensitive permissions requested by ChatUI, see SDK privacy policy.