Skip to content

Commit

Permalink
Added support for Cordova 4
Browse files Browse the repository at this point in the history
  • Loading branch information
gdorigo committed May 3, 2016
1 parent e5cd429 commit 3b94044
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ - (void)notificationReceived {
NSLog(@"Msg: %@", jsonStr);

NSString * jsCallBack = [NSString stringWithFormat:@"%@(%@);", self.callback, jsonStr];
[self.webView stringByEvaluatingJavaScriptFromString:jsCallBack];
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;
}
Expand Down

0 comments on commit 3b94044

Please sign in to comment.