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; } }