Browse Source

fix(iOS): signature of the swizzled `elementDidFocus` method on iOS 13

Evgeniy Yurtaev 5 years ago
parent
commit
68f3c08b54
1 changed files with 13 additions and 3 deletions
  1. 13
    3
      ios/RNCWKWebView.m

+ 13
- 3
ios/RNCWKWebView.m View File

426
   
426
   
427
     NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
427
     NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
428
     NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
428
     NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
429
+    NSOperatingSystemVersion iOS_13_0_0 = (NSOperatingSystemVersion){13, 0, 0};
429
 
430
 
430
     Method method;
431
     Method method;
431
     IMP override;
432
     IMP override;
432
-  
433
-    if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
434
-        // iOS 12.2.0 - Future
433
+
434
+    if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_13_0_0]) {
435
+        // iOS 13.0.0 - Future
436
+        SEL selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:");
437
+        method = class_getInstanceMethod(class, selector);
438
+        IMP original = method_getImplementation(method);
439
+        override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) {
440
+            ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
441
+        });
442
+    }
443
+    else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) {
444
+        // iOS 12.2.0 - iOS 13.0.0
435
         SEL selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:");
445
         SEL selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:");
436
         method = class_getInstanceMethod(class, selector);
446
         method = class_getInstanceMethod(class, selector);
437
         IMP original = method_getImplementation(method);
447
         IMP original = method_getImplementation(method);