From 978b14759824a024b85e6f7a10c97418a11eab34 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Mon, 19 Nov 2018 12:28:25 -0500 Subject: [PATCH] Fix iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blocked on ios 12 (#341) ### Platforms affected iOS ### What does this PR do? fix issue[ #340](https://github.com/apache/cordova-plugin-inappbrowser/issues/340) iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blocked on iOS 12 ### What testing has been done on this change? manual testing ### Checklist - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. - [ ] Added automated test coverage as appropriate for this change. --- src/ios/CDVWKInAppBrowser.m | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 9b515dd04..a952114dd 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -399,30 +399,17 @@ - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper //Synchronus helper for javascript evaluation - -- (NSString *)evaluateJavaScript:(NSString *)script { - __block NSString *resultString = nil; - __block BOOL finished = NO; +- (void)evaluateJavaScript:(NSString *)script { __block NSString* _script = script; - [self.inAppBrowserViewController.webView evaluateJavaScript:script completionHandler:^(id result, NSError *error) { if (error == nil) { if (result != nil) { - resultString = result; - NSLog(@"%@", resultString); + NSLog(@"%@", result); } } else { NSLog(@"evaluateJavaScript error : %@ : %@", error.localizedDescription, _script); } - finished = YES; }]; - - while (!finished) - { - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; - } - - return resultString; } - (void)injectScriptCode:(CDVInvokedUrlCommand*)command