Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
platformThreadHandler = new Handler(wrappedContext.getMainLooper());
// Allow local storage.
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
// Allow zoom.
webView.getSettings().setBuiltInZoomControls(true);
// Hide buttons.
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/ios/Classes/FlutterWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface FLTWebViewController : NSObject <FlutterPlatformView>
@interface FLTWebViewController : NSObject <FlutterPlatformView, WKUIDelegate>

- (instancetype)initWithFrame:(CGRect)frame
viewIdentifier:(int64_t)viewId
Expand Down
14 changes: 14 additions & 0 deletions packages/webview_flutter/ios/Classes/FlutterWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ - (instancetype)initWithFrame:(CGRect)frame

_webView = [[WKWebView alloc] initWithFrame:frame configuration:configuration];
_navigationDelegate = [[FLTWKNavigationDelegate alloc] initWithChannel:_channel];
_webView.UIDelegate = self;
_webView.navigationDelegate = _navigationDelegate;
__weak __typeof__(self) weakSelf = self;
[_channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
Expand Down Expand Up @@ -365,4 +366,17 @@ - (void)updateUserAgent:(NSString*)userAgent {
}
}

#pragma mark WKUIDelegate

- (WKWebView*)webView:(WKWebView*)webView
createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration
forNavigationAction:(WKNavigationAction*)navigationAction
windowFeatures:(WKWindowFeatures*)windowFeatures {
if (!navigationAction.targetFrame.isMainFrame) {
[webView loadRequest:navigationAction.request];
}

return nil;
}

@end