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.
This commit is contained in:
Jonathan Li 2018-11-19 12:28:25 -05:00 committed by Jan Piotrowski
parent 3eadde65ab
commit 978b147598

View File

@ -399,30 +399,17 @@ static CDVWKInAppBrowser* instance = nil;
//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