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) {
}
}
文檔內容是否對您有幫助?