cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [4/9] cordova-plugin-wkwebview-engine git commit: CB-11997: Add crash recovery for iOS 8
Date Thu, 08 Dec 2016 00:57:43 GMT
CB-11997: Add crash recovery for iOS 8


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/d9d30f2c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/tree/d9d30f2c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/diff/d9d30f2c

Branch: refs/heads/1.1.x
Commit: d9d30f2cf91f307b44ecc5efe1763ae7d0b3bdb3
Parents: 81e8898
Author: Connor Pearson <cjp822@gmail.com>
Authored: Tue Oct 11 14:04:37 2016 -0400
Committer: Connor Pearson <cjp822@gmail.com>
Committed: Tue Oct 11 14:04:37 2016 -0400

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/d9d30f2c/src/ios/CDVWKWebViewEngine.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVWKWebViewEngine.m b/src/ios/CDVWKWebViewEngine.m
index 50a872c..9ab0d5c 100644
--- a/src/ios/CDVWKWebViewEngine.m
+++ b/src/ios/CDVWKWebViewEngine.m
@@ -123,6 +123,32 @@
                name:UIApplicationWillEnterForegroundNotification object:nil];
 
     NSLog(@"Using WKWebView");
+
+    [self addURLObserver];
+}
+
+- (void)onReset {
+    [self addURLObserver];
+}
+
+static void * KVOContext = &KVOContext;
+
+- (void)addURLObserver {
+    if(![[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){.majorVersion
= 9, .minorVersion = 0, .patchVersion = 0 }]){
+        [self.webView addObserver:self forKeyPath:@"URL" options:0 context:KVOContext];
+    }
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString
*,id> *)change context:(void *)context
+{
+    if (context == KVOContext) {
+        if (object == [self webView] && [keyPath isEqualToString: @"URL"] &&
[object valueForKeyPath:keyPath] == nil){
+            NSLog(@"URL is nil. Reloading WebView");
+            [(WKWebView*)_engineWebView reload];
+        }
+    } else {
+        [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+    }
 }
 
 - (void) onAppWillEnterForeground:(NSNotification*)notification {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message