From 3000346ba8daebd599c344dd8face440c89d881b Mon Sep 17 00:00:00 2001 From: Jordan Phillips Date: Tue, 18 Jun 2019 10:11:49 -0700 Subject: [PATCH] Update keyboardDisplayRequiresUserAction swizzling for 12.2+ --- ios/RCTWKWebView/CRAWKWebView.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ios/RCTWKWebView/CRAWKWebView.m b/ios/RCTWKWebView/CRAWKWebView.m index fdc27ce3..7c01b5a3 100644 --- a/ios/RCTWKWebView/CRAWKWebView.m +++ b/ios/RCTWKWebView/CRAWKWebView.m @@ -211,9 +211,19 @@ -(void)setKeyboardDisplayRequiresUserAction:(BOOL)keyboardDisplayRequiresUserAct { if (!keyboardDisplayRequiresUserAction) { Class class = NSClassFromString(@"WKContentView"); + + NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0}; NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0}; - - if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) { + + if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) { + SEL selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:"); + Method method = class_getInstanceMethod(class, selector); + IMP original = method_getImplementation(method); + IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) { + ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4); + }); + method_setImplementation(method, override); + } else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) { SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:"); Method method = class_getInstanceMethod(class, selector); IMP original = method_getImplementation(method);