onCreateWindow method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebChromeClient.onCreateWindow', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)', note: 'You need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`. Also, if the request has been created using JavaScript (`window.open()`), then there are some limitation: check the [NavigationAction] class.'), IOSPlatform(apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', note: """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], [InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically], [InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito], [InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture], [InAppWebViewSettings.resourceCustomSchemes], [InAppWebViewSettings.sharedCookiesEnabled], [InAppWebViewSettings.enableViewportScale], [InAppWebViewSettings.allowsAirPlayForMediaPlayback], [InAppWebViewSettings.allowsPictureInPictureMediaPlayback], [InAppWebViewSettings.isFraudulentWebsiteWarningEnabled], [InAppWebViewSettings.allowsInlineMediaPlayback], [InAppWebViewSettings.suppressesIncrementalRendering], [InAppWebViewSettings.selectionGranularity], [InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains], [InAppWebViewSettings.upgradeKnownHostsToHTTPS], will have no effect due to a `WKWebView` limitation when creating the new window WebView: it's impossible to return the new `WKWebView` with a different `WKWebViewConfiguration` instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview). So, these options will be inherited from the caller WebView. Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView, it will update also the WebView options of the caller WebView."""), MacOSPlatform(apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', note: """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], [InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically], [InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito], [InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture], [InAppWebViewSettings.resourceCustomSchemes], [InAppWebViewSettings.sharedCookiesEnabled], [InAppWebViewSettings.enableViewportScale], [InAppWebViewSettings.allowsAirPlayForMediaPlayback], [InAppWebViewSettings.allowsPictureInPictureMediaPlayback], [InAppWebViewSettings.isFraudulentWebsiteWarningEnabled], [InAppWebViewSettings.allowsInlineMediaPlayback], [InAppWebViewSettings.suppressesIncrementalRendering], [InAppWebViewSettings.selectionGranularity], [InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains], [InAppWebViewSettings.upgradeKnownHostsToHTTPS], will have no effect due to a `WKWebView` limitation when creating the new window WebView: it's impossible to return the new `WKWebView` with a different `WKWebViewConfiguration` instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview). So, these options will be inherited from the caller WebView. Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView, it will update also the WebView options of the caller WebView."""), WindowsPlatform(apiName: 'ICoreWebView2.add_NewWindowRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_newwindowrequested')])
- CreateWindowAction createWindowAction
Event fired when the WebView requests the host application to create a new window,
for example when trying to open a link with target="_blank" or when window.open() is called by JavaScript side.
If the host application chooses to honor this request, it should return true from this method, create a new WebView to host the window.
If the host application chooses not to honor the request, it should return false from this method.
The default implementation of this method does nothing and hence returns false.
createWindowActionrepresents the request.
NOTE: to allow JavaScript to open windows, you need to set InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically setting to true.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - WebChromeClient.onCreateWindow):
- You need to set InAppWebViewSettings.supportMultipleWindows setting to
true. Also, if the request has been created using JavaScript (window.open()), then there are some limitation: check the NavigationAction class.
- You need to set InAppWebViewSettings.supportMultipleWindows setting to
- iOS WKWebView (Official API - WKUIDelegate.webView):
- Setting these initial settings InAppWebViewSettings.supportZoom, InAppWebViewSettings.useOnLoadResource, InAppWebViewSettings.useShouldInterceptAjaxRequest, InAppWebViewSettings.useShouldInterceptFetchRequest, InAppWebViewSettings.applicationNameForUserAgent, InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically, InAppWebViewSettings.javaScriptEnabled, InAppWebViewSettings.minimumFontSize, InAppWebViewSettings.preferredContentMode, InAppWebViewSettings.incognito, InAppWebViewSettings.cacheEnabled, InAppWebViewSettings.mediaPlaybackRequiresUserGesture, InAppWebViewSettings.resourceCustomSchemes, InAppWebViewSettings.sharedCookiesEnabled, InAppWebViewSettings.enableViewportScale, InAppWebViewSettings.allowsAirPlayForMediaPlayback, InAppWebViewSettings.allowsPictureInPictureMediaPlayback, InAppWebViewSettings.isFraudulentWebsiteWarningEnabled, InAppWebViewSettings.allowsInlineMediaPlayback, InAppWebViewSettings.suppressesIncrementalRendering, InAppWebViewSettings.selectionGranularity, InAppWebViewSettings.ignoresViewportScaleLimits, InAppWebViewSettings.limitsNavigationsToAppBoundDomains, InAppWebViewSettings.upgradeKnownHostsToHTTPS, will have no effect due to a
WKWebViewlimitation when creating the new window WebView: it's impossible to return the newWKWebViewwith a differentWKWebViewConfigurationinstance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview). So, these options will be inherited from the caller WebView. Also, note that calling InAppWebViewController.setSettings method using the controller of the new created WebView, it will update also the WebView options of the caller WebView.
- Setting these initial settings InAppWebViewSettings.supportZoom, InAppWebViewSettings.useOnLoadResource, InAppWebViewSettings.useShouldInterceptAjaxRequest, InAppWebViewSettings.useShouldInterceptFetchRequest, InAppWebViewSettings.applicationNameForUserAgent, InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically, InAppWebViewSettings.javaScriptEnabled, InAppWebViewSettings.minimumFontSize, InAppWebViewSettings.preferredContentMode, InAppWebViewSettings.incognito, InAppWebViewSettings.cacheEnabled, InAppWebViewSettings.mediaPlaybackRequiresUserGesture, InAppWebViewSettings.resourceCustomSchemes, InAppWebViewSettings.sharedCookiesEnabled, InAppWebViewSettings.enableViewportScale, InAppWebViewSettings.allowsAirPlayForMediaPlayback, InAppWebViewSettings.allowsPictureInPictureMediaPlayback, InAppWebViewSettings.isFraudulentWebsiteWarningEnabled, InAppWebViewSettings.allowsInlineMediaPlayback, InAppWebViewSettings.suppressesIncrementalRendering, InAppWebViewSettings.selectionGranularity, InAppWebViewSettings.ignoresViewportScaleLimits, InAppWebViewSettings.limitsNavigationsToAppBoundDomains, InAppWebViewSettings.upgradeKnownHostsToHTTPS, will have no effect due to a
- macOS WKWebView (Official API - WKUIDelegate.webView):
- Setting these initial settings InAppWebViewSettings.supportZoom, InAppWebViewSettings.useOnLoadResource, InAppWebViewSettings.useShouldInterceptAjaxRequest, InAppWebViewSettings.useShouldInterceptFetchRequest, InAppWebViewSettings.applicationNameForUserAgent, InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically, InAppWebViewSettings.javaScriptEnabled, InAppWebViewSettings.minimumFontSize, InAppWebViewSettings.preferredContentMode, InAppWebViewSettings.incognito, InAppWebViewSettings.cacheEnabled, InAppWebViewSettings.mediaPlaybackRequiresUserGesture, InAppWebViewSettings.resourceCustomSchemes, InAppWebViewSettings.sharedCookiesEnabled, InAppWebViewSettings.enableViewportScale, InAppWebViewSettings.allowsAirPlayForMediaPlayback, InAppWebViewSettings.allowsPictureInPictureMediaPlayback, InAppWebViewSettings.isFraudulentWebsiteWarningEnabled, InAppWebViewSettings.allowsInlineMediaPlayback, InAppWebViewSettings.suppressesIncrementalRendering, InAppWebViewSettings.selectionGranularity, InAppWebViewSettings.ignoresViewportScaleLimits, InAppWebViewSettings.limitsNavigationsToAppBoundDomains, InAppWebViewSettings.upgradeKnownHostsToHTTPS, will have no effect due to a
WKWebViewlimitation when creating the new window WebView: it's impossible to return the newWKWebViewwith a differentWKWebViewConfigurationinstance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview). So, these options will be inherited from the caller WebView. Also, note that calling InAppWebViewController.setSettings method using the controller of the new created WebView, it will update also the WebView options of the caller WebView.
- Setting these initial settings InAppWebViewSettings.supportZoom, InAppWebViewSettings.useOnLoadResource, InAppWebViewSettings.useShouldInterceptAjaxRequest, InAppWebViewSettings.useShouldInterceptFetchRequest, InAppWebViewSettings.applicationNameForUserAgent, InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically, InAppWebViewSettings.javaScriptEnabled, InAppWebViewSettings.minimumFontSize, InAppWebViewSettings.preferredContentMode, InAppWebViewSettings.incognito, InAppWebViewSettings.cacheEnabled, InAppWebViewSettings.mediaPlaybackRequiresUserGesture, InAppWebViewSettings.resourceCustomSchemes, InAppWebViewSettings.sharedCookiesEnabled, InAppWebViewSettings.enableViewportScale, InAppWebViewSettings.allowsAirPlayForMediaPlayback, InAppWebViewSettings.allowsPictureInPictureMediaPlayback, InAppWebViewSettings.isFraudulentWebsiteWarningEnabled, InAppWebViewSettings.allowsInlineMediaPlayback, InAppWebViewSettings.suppressesIncrementalRendering, InAppWebViewSettings.selectionGranularity, InAppWebViewSettings.ignoresViewportScaleLimits, InAppWebViewSettings.limitsNavigationsToAppBoundDomains, InAppWebViewSettings.upgradeKnownHostsToHTTPS, will have no effect due to a
- Windows WebView2 (Official API - ICoreWebView2.add_NewWindowRequested)
Parameters - Officially Supported Platforms/Implementations:
createWindowAction: all platforms
Use the PlatformInAppBrowserEvents.isMethodSupported method to check if this method is supported at runtime.
Implementation
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'WebChromeClient.onCreateWindow',
apiUrl:
'https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)',
note:
'You need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`. Also, if the request has been created using JavaScript (`window.open()`), then there are some limitation: check the [NavigationAction] class.',
),
IOSPlatform(
apiName: 'WKUIDelegate.webView',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview',
note:
"""Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest],
[InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically],
[InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito],
[InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture],
[InAppWebViewSettings.resourceCustomSchemes], [InAppWebViewSettings.sharedCookiesEnabled],
[InAppWebViewSettings.enableViewportScale], [InAppWebViewSettings.allowsAirPlayForMediaPlayback],
[InAppWebViewSettings.allowsPictureInPictureMediaPlayback], [InAppWebViewSettings.isFraudulentWebsiteWarningEnabled],
[InAppWebViewSettings.allowsInlineMediaPlayback], [InAppWebViewSettings.suppressesIncrementalRendering], [InAppWebViewSettings.selectionGranularity],
[InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains],
[InAppWebViewSettings.upgradeKnownHostsToHTTPS],
will have no effect due to a `WKWebView` limitation when creating the new window WebView: it's impossible to return the new `WKWebView`
with a different `WKWebViewConfiguration` instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview).
So, these options will be inherited from the caller WebView.
Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView,
it will update also the WebView options of the caller WebView.""",
),
MacOSPlatform(
apiName: 'WKUIDelegate.webView',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview',
note:
"""Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest],
[InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically],
[InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito],
[InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture],
[InAppWebViewSettings.resourceCustomSchemes], [InAppWebViewSettings.sharedCookiesEnabled],
[InAppWebViewSettings.enableViewportScale], [InAppWebViewSettings.allowsAirPlayForMediaPlayback],
[InAppWebViewSettings.allowsPictureInPictureMediaPlayback], [InAppWebViewSettings.isFraudulentWebsiteWarningEnabled],
[InAppWebViewSettings.allowsInlineMediaPlayback], [InAppWebViewSettings.suppressesIncrementalRendering], [InAppWebViewSettings.selectionGranularity],
[InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains],
[InAppWebViewSettings.upgradeKnownHostsToHTTPS],
will have no effect due to a `WKWebView` limitation when creating the new window WebView: it's impossible to return the new `WKWebView`
with a different `WKWebViewConfiguration` instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview).
So, these options will be inherited from the caller WebView.
Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView,
it will update also the WebView options of the caller WebView.""",
),
WindowsPlatform(
apiName: 'ICoreWebView2.add_NewWindowRequested',
apiUrl:
'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_newwindowrequested',
),
],
)
FutureOr<bool?>? onCreateWindow(CreateWindowAction createWindowAction) {
return null;
}