mPaaS 内核支持 WebRTC,需要设置录音和相机的权限授权。
WebRTC permission 授权
初始化完成后通过 Provider 设置自定义 permission 处理器。
H5Utils.setProvider(MPH5WebChromeClientProvider.class.getName(), new MPH5WebChromeClientProvider() {
@Override
public H5WebChromeClient generateH5WebChromeClient(H5PageImpl h5Page) {
return new CustomH5WebChromeClient(h5Page);
}
});
package com.mpaas.demo;
import android.webkit.PermissionRequest;
import com.alipay.mobile.nebulacore.core.H5PageImpl;
import com.alipay.mobile.nebulacore.web.H5WebChromeClient;
public class CustomH5WebChromeClient extends H5WebChromeClient {
public CustomH5WebChromeClient() {
}
public CustomH5WebChromeClient(H5PageImpl page) {
super(page);
}
@Override
public void onPermissionRequest(PermissionRequest request) {
//检查app是否包含权限,不包含的话需要申请对应权限。
// 权限已授权调用grant
//request.grant(request.getResources());
//如果权限被拒绝,调用deny
// request.deny(request.getResources());
}
@Override
public void onPermissionRequestCanceled(PermissionRequest request) {
}
}
文档内容是否对您有帮助?