onPermissionRequest method
Event fired when the WebView is requesting permission to access the specified resources and the permission currently isn't granted or denied.
permissionRequest represents the permission request with an array of resources the web content wants to access
and the origin of the web page which is trying to access the restricted resources.
Officially Supported Platforms/Implementations:
- Android WebView 21+ (Official API - WebChromeClient.onPermissionRequest)
- iOS WKWebView 15.0+:
- The default
PermissionResponse.actionisPermissionResponseAction.PROMPT.
- The default
- macOS WKWebView 12.0+:
- The default
PermissionResponse.actionisPermissionResponseAction.PROMPT.
- The default
- Windows WebView2 (Official API - ICoreWebView2.add_PermissionRequested)
Parameters - Officially Supported Platforms/Implementations:
permissionRequest: all platforms
Use the PlatformInAppBrowserEvents.isMethodSupported method to check if this method is supported at runtime.
Implementation
@override
Future<PermissionResponse> onPermissionRequest(permissionRequest) async {
return PermissionResponse(
resources: permissionRequest.resources,
action: PermissionResponseAction.GRANT,
);
}