From ddaa7a1548b01eccbc7f3fdd24f7356057c3931e Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Tue, 1 Mar 2016 20:27:21 +0100 Subject: [PATCH] #60 Add support for Cordova-iOS 4 #71 PushPlugin.m error: no visible @interface for 'UIView' declares the selector 'stringByEvaluatingJavaScriptFromString:' --- src/ios/PushPlugin.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index 96dbca3c..77750065 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -425,8 +425,14 @@ - (void)notificationReceived { [jsonStr appendString:@"}"]; NSString * jsCallBack = [NSString stringWithFormat:@"%@(%@);", self.callback, jsonStr]; - [self.webView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:jsCallBack waitUntilDone:NO]; - + if ([self.webView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) { + // Cordova-iOS pre-4 + [self.webView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:jsCallBack waitUntilDone:NO]; + } else { + // Cordova-iOS 4+ + [self.webView performSelectorOnMainThread:@selector(evaluateJavaScript:completionHandler:) withObject:jsCallBack waitUntilDone:NO]; + } + self.notificationMessage = nil; } }