From 0d85a7dee56e0f495d160a8834dd7ef8f47b2207 Mon Sep 17 00:00:00 2001 From: Jonas <8239699+JH7@users.noreply.github.com> Date: Tue, 17 May 2022 21:21:30 +0200 Subject: [PATCH] (iOS) fix reload issue resulting in white screen --- .../Plugins/CDVWebViewEngine/CDVWebViewEngine.m | 10 ++++++++-- CordovaLib/include/Cordova/CDVViewController.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m b/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m index 8e1094e7c9..812e14d3f4 100644 --- a/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m +++ b/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m @@ -283,7 +283,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N - (void) onAppWillEnterForeground:(NSNotification*)notification { if ([self shouldReloadWebView]) { NSLog(@"%@", @"CDVWebViewEngine reloading!"); - [(WKWebView*)_engineWebView reload]; + NSURL* url = [((CDVViewController*) self.viewController) appUrl]; + NSURLRequest* appReq = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0]; + [self loadRequest:appReq]; } } @@ -529,7 +531,11 @@ - (void)webView:(WKWebView*)theWebView didFailNavigation:(WKNavigation*)navigati - (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView { - [webView reload]; + CDVViewController *vc = (CDVViewController *)self.viewController; + [vc showLaunchScreen:true]; + NSURL* url = [vc appUrl]; + NSURLRequest* appReq = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0]; + [self loadRequest:appReq]; } - (BOOL)defaultResourcePolicyForURL:(NSURL*)url diff --git a/CordovaLib/include/Cordova/CDVViewController.h b/CordovaLib/include/Cordova/CDVViewController.h index 945709ff03..6388582ec6 100644 --- a/CordovaLib/include/Cordova/CDVViewController.h +++ b/CordovaLib/include/Cordova/CDVViewController.h @@ -83,6 +83,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable NSString*)appURLScheme; - (nullable NSURL*)errorURL; +- (NSURL*)appUrl; - (NSArray*)parseInterfaceOrientations:(NSArray*)orientations; - (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation;