Skip to content
Permalink
Browse files
Fix iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blo…
…cked on ios 12 (#341)

### Platforms affected
iOS

### What does this PR do?
fix issue[ #340](#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.
  • Loading branch information
jonathanli2 authored and janpio committed Nov 19, 2018
1 parent 3eadde6 commit 978b14759824a024b85e6f7a10c97418a11eab34
Showing 1 changed file with 2 additions and 15 deletions.
@@ -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

0 comments on commit 978b147

Please sign in to comment.