Skip to content

Commit 51c35ec

Browse files
committed
watch webKit error 101
1 parent 52d0e2d commit 51c35ec

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

WebViewJavascriptBridge/WebViewJavascriptBridge.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ @implementation WebViewJavascriptBridge {
1919
WVJB_WEAK id _webViewDelegate;
2020
long _uniqueId;
2121
WebViewJavascriptBridgeBase *_base;
22+
#if defined WVJB_PLATFORM_IOS
23+
NSUInteger _numRequestsLoading;
24+
#endif
2225
}
2326

2427
/* API
@@ -183,9 +186,9 @@ - (void) _platformSpecificDealloc {
183186

184187
- (void)webViewDidFinishLoad:(UIWebView *)webView {
185188
if (webView != _webView) { return; }
186-
189+
_numRequestsLoading--;
187190

188-
if ( ![[webView stringByEvaluatingJavaScriptFromString:[_base webViewJavascriptCheckCommand]] isEqualToString:@"true"]) {
191+
if ( _numRequestsLoading <= 0 && ![[webView stringByEvaluatingJavaScriptFromString:[_base webViewJavascriptCheckCommand]] isEqualToString:@"true"]) {
189192
[_base injectJavascriptFile:YES];
190193
}
191194
[_base dispatchStartUpMessageQueue];
@@ -200,7 +203,8 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView {
200203
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
201204
if (webView != _webView) { return; }
202205

203-
206+
_numRequestsLoading--;
207+
//watch error code 101
204208
__strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
205209
if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
206210
[strongDelegate webView:webView didFailLoadWithError:error];
@@ -228,7 +232,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
228232

229233
- (void)webViewDidStartLoad:(UIWebView *)webView {
230234
if (webView != _webView) { return; }
231-
235+
_numRequestsLoading++;
232236

233237
__strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
234238
if (strongDelegate && [strongDelegate respondsToSelector:@selector(webViewDidStartLoad:)]) {

WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ @implementation WebViewJavascriptBridgeBase {
1212
id _webViewDelegate;
1313
long _uniqueId;
1414
NSBundle *_resourceBundle;
15+
1516
}
1617

1718
static bool logging = false;

0 commit comments

Comments
 (0)