Custom Permission Request Handling
Global IM UIKit's chat UI provides functionalities such as sending images, voice messages, files, and initiating calls. When invoking APIs that involve sensitive permissions, Global IM UIKit will request permissions from the user and will only proceed with the task after the permissions are granted.
Global IM UIKit does not expose the UI related to permission requests. If your application needs to customize the UI for permission requests, you can intercept Global IM UIKit's permission requests. For example, the application can inform users about the purpose of requesting sensitive permissions on a custom page when Global IM UIKit requests such permissions, thereby meeting the compliance requirements for app store listings.
Intercepting Permission Requests
It is recommended to use ConfigCenter
to obtain FeatureConfig before entering the chat UI, and use the setPermissionInterceptor method to set up a permission request listener. In the onRequestPermission
callback of PermissionInterceptor, you can customize the handling of permission requests.
After processing the permissions, inform Global IM UIKit of the permission request result via the Callback
in PermissionInterceptor. onConfirm
indicates that the permission is granted, while onCancel
indicates that the permission is denied.
ConfigCenter.getFeatureConfig().setPermissionInterceptor(new PermissionInterceptor() {
@Override
public void onRequestPermission(@NonNull Context activity, @NonNull List<String> permissionsNotGranted, @NonNull CallBack callback) {
new AlertDialog.Builder(
activity,
android.R
.style
.Theme_DeviceDefault_Light_Dialog_Alert)
.setMessage("Explain the purpose of requesting permissions to the user")
.setPositiveButton(
"Request",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog, int which) {
dialog.dismiss();
callback.onConfirm();
}
})
.setNegativeButton(
"Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog, int which) {
dialog.dismiss();
callback.onCancel();
}
})
.show();
}
});