11#import " CDVWKWebViewEngine+InputFocusFix.h"
2+ #import < objc/runtime.h>
23
34@implementation CDVWKWebViewEngine (InputFocusFix)
45+ (void ) load {
@@ -18,13 +19,25 @@ - (void) swizzleWKContentViewForInputFocus {
1819
1920// https://github.com/Telerik-Verified-Plugins/WKWebView/commit/04e8296adeb61f289f9c698045c19b62d080c7e3
2021- (void ) keyboardDisplayDoesNotRequireUserAction {
21- SEL sel = sel_getUid (" _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:" );
22- Class WKContentView = NSClassFromString (@" WKContentView" );
23- Method method = class_getInstanceMethod (WKContentView, sel);
24- IMP originalImp = method_getImplementation (method);
25- IMP imp = imp_implementationWithBlock (^void (id me, void * arg0, BOOL arg1, BOOL arg2, id arg3) {
26- ((void (*)(id , SEL , void *, BOOL , BOOL , id ))originalImp)(me, sel, arg0, TRUE , arg2, arg3);
27- });
28- method_setImplementation (method, imp);
22+ Class class = NSClassFromString (@" WKContentView" );
23+ NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion ){11 , 3 , 0 };
24+
25+ if ([[NSProcessInfo processInfo ] isOperatingSystemAtLeastVersion: iOS_11_3_0]) {
26+ SEL selector = sel_getUid (" _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:" );
27+ Method method = class_getInstanceMethod (class, selector);
28+ IMP original = method_getImplementation (method);
29+ IMP override = imp_implementationWithBlock (^void (id me, void * arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
30+ ((void (*)(id , SEL , void *, BOOL , BOOL , BOOL , id ))original)(me, selector, arg0, TRUE , arg2, arg3, arg4);
31+ });
32+ method_setImplementation (method, override);
33+ } else {
34+ SEL selector = sel_getUid (" _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:" );
35+ Method method = class_getInstanceMethod (class, selector);
36+ IMP original = method_getImplementation (method);
37+ IMP override = imp_implementationWithBlock (^void (id me, void * arg0, BOOL arg1, BOOL arg2, id arg3) {
38+ ((void (*)(id , SEL , void *, BOOL , BOOL , id ))original)(me, selector, arg0, TRUE , arg2, arg3);
39+ });
40+ method_setImplementation (method, override);
41+ }
2942}
30- @end
43+ @end
0 commit comments