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

Commit

Permalink
#46 keyboardDisplayRequiresUserAction doesn't work
Browse files Browse the repository at this point in the history
#184 KeyboardDisplayRequiresUserAction workaround
  • Loading branch information
EddyVerbruggen committed Oct 22, 2015
1 parent 8d43287 commit 04e8296
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ $ cordova plugin add cordova-plugin-wkwebview --variable WKWEBVIEW_SERVER_PORT=1
No need for anything else - you can now open the project in XCode 6 if you like.

## 4. Changelog
* __0.6.5__ `KeyboardDisplayRequiresUserAction` works! So set to `false` if you want the keyboard to pop up when programmatically focussing an input field.
* __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').
* __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`.
* __0.6.2__ LocalStorage is copied from UIWebView to WKWebView again (iOS location was recently changed as it appears).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.6.4",
"version": "0.6.5",
"name": "cordova-plugin-wkwebview",
"cordova_name": "WKWebView Polyfill",
"description": "A drop-in replacement of UIWebView for boosted performance and enhanced HTML5 support",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="com.telerik.plugins.wkwebview"
version="0.6.4">
version="0.6.5">

<name>WKWebView Polyfill</name>

Expand Down
17 changes: 17 additions & 0 deletions src/ios/MyMainViewController.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import <objc/runtime.h>
#import "MyMainViewController.h"
#import <Cordova/CDVTimer.h>
#import <Cordova/CDVLocalStorage.h>
Expand Down Expand Up @@ -392,6 +393,10 @@ - (void)viewDidLoad
if ([self.webView respondsToSelector:@selector(setKeyboardDisplayRequiresUserAction:)]) {
[self.webView setValue:[NSNumber numberWithBool:keyboardDisplayRequiresUserAction] forKey:@"keyboardDisplayRequiresUserAction"];
}

if (!keyboardDisplayRequiresUserAction) {
[self keyboardDisplayDoesNotRequireUserAction];
}
}

/*
Expand Down Expand Up @@ -601,6 +606,18 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
decisionHandler(WKNavigationActionPolicyAllow);
}

// this is by far the weirest piece of code I've produced to date (swizzling a private method)
- (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);
}

#pragma mark WKScriptMessageHandler implementation

#ifdef __IPHONE_8_0
Expand Down

0 comments on commit 04e8296

Please sign in to comment.