Skip to content

Commit 42dc470

Browse files
authored
Merge pull request #2 from dpa99c/joel
Fix KeyboardDisplayRequiresUserAction setting
2 parents acc43d7 + 930f228 commit 42dc470

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/ios/CDVWKWebViewEngine.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ - (void)pluginInitialize
142142
if ([self.viewController conformsToProtocol:@protocol(WKScriptMessageHandler)]) {
143143
[wkWebView.configuration.userContentController addScriptMessageHandler:(id < WKScriptMessageHandler >)self.viewController name:CDV_BRIDGE_NAME];
144144
}
145+
if (![settings cordovaBoolSettingForKey:@"KeyboardDisplayRequiresUserAction" defaultValue:YES]) {
146+
[self keyboardDisplayDoesNotRequireUserAction];
147+
}
145148

146149
[self updateSettings:settings];
147150

@@ -169,6 +172,18 @@ - (void)addURLObserver {
169172
}
170173
}
171174

175+
// https://github.com/Telerik-Verified-Plugins/WKWebView/commit/04e8296adeb61f289f9c698045c19b62d080c7e3#L609-L620
176+
- (void) keyboardDisplayDoesNotRequireUserAction {
177+
SEL sel = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
178+
Class WKContentView = NSClassFromString(@"WKContentView");
179+
Method method = class_getInstanceMethod(WKContentView, sel);
180+
IMP originalImp = method_getImplementation(method);
181+
IMP imp = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
182+
((void (*)(id, SEL, void*, BOOL, BOOL, id))originalImp)(me, sel, arg0, TRUE, arg2, arg3);
183+
});
184+
method_setImplementation(method, imp);
185+
}
186+
172187
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
173188
{
174189
if (context == KVOContext) {

0 commit comments

Comments
 (0)