Github user shazron commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-wkwebview-engine/pull/23#discussion_r90092299
--- Diff: src/ios/CDVWKWebViewEngine.m ---
@@ -123,6 +123,32 @@ - (void)pluginInitialize
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");
--- End diff --
Change WebView to WKWebView to give more clarity in the log here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]