99#import < React/RCTConvert.h>
1010#import < React/RCTAutoInsetsProtocol.h>
1111#import " RNCWKProcessPoolManager.h"
12+ #import " RNCWebViewDecisionManager.h"
1213#if !TARGET_OS_OSX
1314#import < UIKit/UIKit.h>
1415#else
@@ -1122,6 +1123,16 @@ - (void) webView:(WKWebView *)webView
11221123 };
11231124
11241125 if (_onShouldStartLoadWithRequest) {
1126+ int lockIdentifier = [[RNCWebViewDecisionManager getInstance ] setDecisionHandler: ^(BOOL shouldStart) {
1127+ dispatch_async (dispatch_get_main_queue (), ^{
1128+ if (!shouldStart) {
1129+ decisionHandler (WKNavigationActionPolicyCancel );
1130+ return ;
1131+ }
1132+ allowNavigation ();
1133+ });
1134+ }];
1135+
11251136 NSMutableDictionary <NSString *, id > *event = [self baseEvent ];
11261137 if (request.mainDocumentURL ) {
11271138 [event addEntriesFromDictionary: @{
@@ -1131,14 +1142,11 @@ - (void) webView:(WKWebView *)webView
11311142 [event addEntriesFromDictionary: @{
11321143 @" url" : (request.URL ).absoluteString ,
11331144 @" navigationType" : navigationTypes[@(navigationType)],
1134- @" isTopFrame" : @(isTopFrame)
1145+ @" isTopFrame" : @(isTopFrame),
1146+ @" lockIdentifier" : @(lockIdentifier)
11351147 }];
1136- if (![self .delegate webView: self
1137- shouldStartLoadForRequest: event
1138- withCallback: _onShouldStartLoadWithRequest]) {
1139- decisionHandler (WKNavigationActionPolicyCancel );
1140- return ;
1141- }
1148+ _onShouldStartLoadWithRequest (event);
1149+ return ;
11421150 }
11431151
11441152 // Allow all navigation by default
0 commit comments