Skip to main content

Custom Permission Request Handling

The RC Chat UI in IMKit SDK provides features such as sending images, voice messages, files, and initiating calls. When invoking APIs that involve sensitive permissions, IMKit will request user permissions and proceed with the task only after permissions are granted.

IMKit does not expose the UI for permission requests. If your app requires custom permission request UI, you can intercept IMKit's permission requests. For example, your app can simultaneously explain the purpose of sensitive permission requests to users on a custom page when IMKit requests them, meeting compliance requirements for app store submissions.

Intercepting Permission Requests

tip

The following method cannot intercept permission requests for taking photos from the album in IMKit development versions below 5.6.3. We recommend using the latest development version. Stable SDK versions support this feature starting from 5.7.0.

We recommend using the PermissionCheckUtil's setRequestPermissionListListener method before entering the chat UI. Implement the onRequestPermissionList callback to handle permission requests customly.

After processing the permissions, notify IMKit of the permission request result via IPermissionEventCallback. Use confirmed to indicate granted permissions and cancelled for denied permissions.

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 permission purpose to users")
.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();
}
});

Reference Resources