From eb859b37a6bb3ff283668c1c97aa85af41df7a2a Mon Sep 17 00:00:00 2001 From: Luke Miles Date: Mon, 22 Feb 2016 17:15:26 -0800 Subject: [PATCH] fix issue with casting types --- package.json | 2 +- src/ios/screenshot.m | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index cc09732..950f0e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-detect-screenshot", - "version": "1.0.2", + "version": "1.0.3", "description": "Detects screenshots on iOS", "cordova": { "id": "com.lukemiles.screenshot", diff --git a/src/ios/screenshot.m b/src/ios/screenshot.m index a35ab00..2b7774b 100644 --- a/src/ios/screenshot.m +++ b/src/ios/screenshot.m @@ -12,10 +12,11 @@ - (void)pluginInitialize object:nil queue:mainQueue usingBlock:^(NSNotification *note) { - if ([self.webView isKindOfClass:[UIWebView class]]) { - [(UIWebView*)self.webView stringByEvaluatingJavaScriptFromString:"cordova.fireDocumentEvent('screenshot');"]; + if ([self.webView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) { + [self.webView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:@"cordova.fireDocumentEvent('screenshot');" waitUntilDone:NO]; } else { - [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('screenshot');"]; + // cordova lib version is > 4 + [self.webView performSelectorOnMainThread:@selector(evaluateJavaScript:completionHandler:) withObject:@"cordova.fireDocumentEvent('screenshot');" waitUntilDone:NO]; } }]; }