Skip to content

Commit 978b147

Browse files
jonathanli2janpio
authored andcommitted
Fix iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blocked 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.
1 parent 3eadde6 commit 978b147

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/ios/CDVWKInAppBrowser.m

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -399,30 +399,17 @@ - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
399399

400400

401401
//Synchronus helper for javascript evaluation
402-
403-
- (NSString *)evaluateJavaScript:(NSString *)script {
404-
__block NSString *resultString = nil;
405-
__block BOOL finished = NO;
402+
- (void)evaluateJavaScript:(NSString *)script {
406403
__block NSString* _script = script;
407-
408404
[self.inAppBrowserViewController.webView evaluateJavaScript:script completionHandler:^(id result, NSError *error) {
409405
if (error == nil) {
410406
if (result != nil) {
411-
resultString = result;
412-
NSLog(@"%@", resultString);
407+
NSLog(@"%@", result);
413408
}
414409
} else {
415410
NSLog(@"evaluateJavaScript error : %@ : %@", error.localizedDescription, _script);
416411
}
417-
finished = YES;
418412
}];
419-
420-
while (!finished)
421-
{
422-
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
423-
}
424-
425-
return resultString;
426413
}
427414

428415
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command

0 commit comments

Comments
 (0)