Repository: cordova-plugin-wkwebview-engine
Updated Branches:
  refs/heads/master 7c8d3a4cb -> c9d7e5511


CB-10190 - WKWebView engine is not releasing the user-agent lock


Project: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/commit/c9d7e551
Tree: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/tree/c9d7e551
Diff: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/diff/c9d7e551

Branch: refs/heads/master
Commit: c9d7e5511d73b028b359a51844e9b1e26a08f12a
Parents: 7c8d3a4
Author: Shazron Abdullah <[email protected]>
Authored: Fri Dec 11 09:34:15 2015 -0800
Committer: Shazron Abdullah <[email protected]>
Committed: Fri Dec 11 09:34:15 2015 -0800

----------------------------------------------------------------------
 src/ios/CDVWKWebViewEngine.m | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/c9d7e551/src/ios/CDVWKWebViewEngine.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVWKWebViewEngine.m b/src/ios/CDVWKWebViewEngine.m
index 94ddeff..7d270f7 100644
--- a/src/ios/CDVWKWebViewEngine.m
+++ b/src/ios/CDVWKWebViewEngine.m
@@ -258,9 +258,28 @@
 
 - (void)webView:(WKWebView*)webView 
didFinishNavigation:(WKNavigation*)navigation
 {
+    CDVViewController* vc = (CDVViewController*)self.viewController;
+    [CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
+    
     [[NSNotificationCenter defaultCenter] postNotification:[NSNotification 
notificationWithName:CDVPageDidLoadNotification object:webView]];
 }
 
+- (void)webView:(WKWebView*)theWebView 
didFailNavigation:(WKNavigation*)navigation withError:(NSError*)error
+{
+    CDVViewController* vc = (CDVViewController*)self.viewController;
+    [CDVUserAgentUtil releaseLock:vc.userAgentLockToken];
+    
+    NSString* message = [NSString stringWithFormat:@"Failed to load webpage 
with error: %@", [error localizedDescription]];
+    NSLog(@"%@", message);
+    
+    NSURL* errorUrl = vc.errorURL;
+    if (errorUrl) {
+        errorUrl = [NSURL URLWithString:[NSString 
stringWithFormat:@"?error=%@", [message 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] 
relativeToURL:errorUrl];
+        NSLog(@"%@", [errorUrl absoluteString]);
+        [theWebView loadRequest:[NSURLRequest requestWithURL:errorUrl]];
+    }
+}
+
 - (BOOL)defaultResourcePolicyForURL:(NSURL*)url
 {
     // all file:// urls are allowed


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to