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

Fix bug where WKWebView doesn't respect the KeyboardDisplayRequiresUserAction setting #171

Merged
merged 1 commit into from
Sep 20, 2017
Merged
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
16 changes: 16 additions & 0 deletions src/ios/CDVWKWebViewEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ - (void)pluginInitialize
if ([self.viewController conformsToProtocol:@protocol(WKScriptMessageHandler)]) {
[wkWebView.configuration.userContentController addScriptMessageHandler:(id < WKScriptMessageHandler >)self.viewController name:CDV_BRIDGE_NAME];
}

if (![settings cordovaBoolSettingForKey:@"KeyboardDisplayRequiresUserAction" defaultValue:YES]) {
[self keyboardDisplayDoesNotRequireUserAction];
}

[self updateSettings:settings];

Expand All @@ -167,6 +171,18 @@ - (void)pluginInitialize
[self addURLObserver];
}

// https://github.com/Telerik-Verified-Plugins/WKWebView/commit/04e8296adeb61f289f9c698045c19b62d080c7e3#L609-L620
- (void) keyboardDisplayDoesNotRequireUserAction {
SEL sel = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
Class WKContentView = NSClassFromString(@"WKContentView");
Method method = class_getInstanceMethod(WKContentView, sel);
IMP originalImp = method_getImplementation(method);
IMP imp = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
((void (*)(id, SEL, void*, BOOL, BOOL, id))originalImp)(me, sel, arg0, TRUE, arg2, arg3);
});
method_setImplementation(method, imp);
}

- (void)onReset {
[self addURLObserver];
}
Expand Down