Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 83a9fed

Browse files
author
Igor Krasavin
authored
Update didFailNavigation method (#642)
1 parent 395984c commit 83a9fed

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/ios/CDVWKWebViewEngine+CodePush.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,25 @@ - (void)webView:(WKWebView*)theWebView didFailNavigation:(WKNavigation*)navigati
9696
} else {
9797
// Default implementation of didFailNavigation method of CDVWKWebViewEngine.m
9898
CDVViewController* vc = (CDVViewController*)self.viewController;
99+
#ifndef __CORDOVA_6_0_0
100+
[CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
101+
#endif
102+
99103
NSString* message = [NSString stringWithFormat:@"Failed to load webpage with error: %@", [error localizedDescription]];
100104
NSLog(@"%@", message);
101-
[CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
105+
102106
NSURL* errorUrl = vc.errorURL;
103107
if (errorUrl) {
104-
errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [message stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] relativeToURL:errorUrl];
108+
NSCharacterSet *charSet = [NSCharacterSet URLFragmentAllowedCharacterSet];
109+
errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [message stringByAddingPercentEncodingWithAllowedCharacters:charSet]] relativeToURL:errorUrl];
105110
NSLog(@"%@", [errorUrl absoluteString]);
106111
[theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
107112
}
113+
#ifdef DEBUG
114+
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] message:message preferredStyle:UIAlertControllerStyleAlert];
115+
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) style:UIAlertActionStyleDefault handler:nil]];
116+
[vc presentViewController:alertController animated:YES completion:nil];
117+
#endif
108118
}
109119
}
110120

0 commit comments

Comments
 (0)