Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

Commit 04e8296

Browse files
#46 keyboardDisplayRequiresUserAction doesn't work
#184 KeyboardDisplayRequiresUserAction workaround
1 parent 8d43287 commit 04e8296

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ $ cordova plugin add cordova-plugin-wkwebview --variable WKWEBVIEW_SERVER_PORT=1
5454
No need for anything else - you can now open the project in XCode 6 if you like.
5555

5656
## 4. Changelog
57+
* __0.6.5__ `KeyboardDisplayRequiresUserAction` works! So set to `false` if you want the keyboard to pop up when programmatically focussing an input field.
5758
* __0.6.4__ On top of the port preference introduced in 0.6.3 you can now override the default variable when installing this plugin (see 'Installation').
5859
* __0.6.3__ By default the embedded webserver uses port `12344`, but if you want to you can now override that port by setting f.i. `<preference name="WKWebViewPluginEmbeddedServerPort" value="20000" />` in `config.xml`.
5960
* __0.6.2__ LocalStorage is copied from UIWebView to WKWebView again (iOS location was recently changed as it appears).

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.6.4",
2+
"version": "0.6.5",
33
"name": "cordova-plugin-wkwebview",
44
"cordova_name": "WKWebView Polyfill",
55
"description": "A drop-in replacement of UIWebView for boosted performance and enhanced HTML5 support",

plugin.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
33
id="com.telerik.plugins.wkwebview"
4-
version="0.6.4">
4+
version="0.6.5">
55

66
<name>WKWebView Polyfill</name>
77

src/ios/MyMainViewController.m

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#import <objc/runtime.h>
12
#import "MyMainViewController.h"
23
#import <Cordova/CDVTimer.h>
34
#import <Cordova/CDVLocalStorage.h>
@@ -392,6 +393,10 @@ - (void)viewDidLoad
392393
if ([self.webView respondsToSelector:@selector(setKeyboardDisplayRequiresUserAction:)]) {
393394
[self.webView setValue:[NSNumber numberWithBool:keyboardDisplayRequiresUserAction] forKey:@"keyboardDisplayRequiresUserAction"];
394395
}
396+
397+
if (!keyboardDisplayRequiresUserAction) {
398+
[self keyboardDisplayDoesNotRequireUserAction];
399+
}
395400
}
396401

397402
/*
@@ -601,6 +606,18 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
601606
decisionHandler(WKNavigationActionPolicyAllow);
602607
}
603608

609+
// this is by far the weirest piece of code I've produced to date (swizzling a private method)
610+
- (void) keyboardDisplayDoesNotRequireUserAction {
611+
SEL sel = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
612+
Class WKContentView = NSClassFromString(@"WKContentView");
613+
Method method = class_getInstanceMethod(WKContentView, sel);
614+
IMP originalImp = method_getImplementation(method);
615+
IMP imp = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
616+
((void (*)(id, SEL, void*, BOOL, BOOL, id))originalImp)(me, sel, arg0, TRUE, arg2, arg3);
617+
});
618+
method_setImplementation(method, imp);
619+
}
620+
604621
#pragma mark WKScriptMessageHandler implementation
605622

606623
#ifdef __IPHONE_8_0

0 commit comments

Comments
 (0)