From 7c71ef97c34d236b9d0aa2049a479ac13fd3cafd Mon Sep 17 00:00:00 2001 From: Alex Quach Date: Wed, 7 Sep 2016 09:52:56 -0700 Subject: [PATCH] Add support for WKWebView. --- src/ios/screenshot.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ios/screenshot.m b/src/ios/screenshot.m index 2b7774b..f93ded6 100644 --- a/src/ios/screenshot.m +++ b/src/ios/screenshot.m @@ -13,7 +13,11 @@ - (void)pluginInitialize queue:mainQueue usingBlock:^(NSNotification *note) { if ([self.webView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) { + // UIWebView [self.webView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:@"cordova.fireDocumentEvent('screenshot');" waitUntilDone:NO]; + } else if ([self.webView respondsToSelector:@selector(evaluateJavaScript:completionHandler:)]) { + // WKWebView + [self.webView performSelector:@selector(evaluateJavaScript:completionHandler:) withObject:@"cordova.fireDocumentEvent('screenshot');" withObject:nil]; } else { // cordova lib version is > 4 [self.webView performSelectorOnMainThread:@selector(evaluateJavaScript:completionHandler:) withObject:@"cordova.fireDocumentEvent('screenshot');" waitUntilDone:NO]; @@ -22,4 +26,4 @@ - (void)pluginInitialize } } - @end \ No newline at end of file + @end