Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.

Commit fb21e8b

Browse files
authored
Merge pull request #171 from onderceylan/master
Fix bug where WKWebView doesn't respect the KeyboardDisplayRequiresUserAction setting
2 parents 3f6be80 + 8409dbb commit fb21e8b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ios/CDVWKWebViewEngine.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ - (void)pluginInitialize
152152
if ([self.viewController conformsToProtocol:@protocol(WKScriptMessageHandler)]) {
153153
[wkWebView.configuration.userContentController addScriptMessageHandler:(id < WKScriptMessageHandler >)self.viewController name:CDV_BRIDGE_NAME];
154154
}
155+
156+
if (![settings cordovaBoolSettingForKey:@"KeyboardDisplayRequiresUserAction" defaultValue:YES]) {
157+
[self keyboardDisplayDoesNotRequireUserAction];
158+
}
155159

156160
[self updateSettings:settings];
157161

@@ -167,6 +171,18 @@ - (void)pluginInitialize
167171
[self addURLObserver];
168172
}
169173

174+
// https://github.com/Telerik-Verified-Plugins/WKWebView/commit/04e8296adeb61f289f9c698045c19b62d080c7e3#L609-L620
175+
- (void) keyboardDisplayDoesNotRequireUserAction {
176+
SEL sel = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
177+
Class WKContentView = NSClassFromString(@"WKContentView");
178+
Method method = class_getInstanceMethod(WKContentView, sel);
179+
IMP originalImp = method_getImplementation(method);
180+
IMP imp = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
181+
((void (*)(id, SEL, void*, BOOL, BOOL, id))originalImp)(me, sel, arg0, TRUE, arg2, arg3);
182+
});
183+
method_setImplementation(method, imp);
184+
}
185+
170186
- (void)onReset {
171187
[self addURLObserver];
172188
}

0 commit comments

Comments
 (0)