Coredova pass the data to javascipt function from pushNotification iOS Objective C

Problem:

How to solve the push notification data to evaluate from javascript in objective c Cordova project?

Solution:

In Cordova you get the data from push notification in the form of dictionary and you can parse it and evaluate in objective c.But if you want to pass it to the javascript function in Cordova and evaluate then the below function was useful.


-(void)webCall:(NSString *)notifyJS {
    if ([self.webView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) {
        dispatch_sync(dispatch_get_main_queue(), ^{
            
            [(UIWebView *)self.webView stringByEvaluatingJavaScriptFromString:notifyJS];
        });
        
    } else {
        [self.webViewEngine evaluateJavaScript:notifyJS completionHandler:nil];
    }
    
}



In Webstring you can call the javascript function with its parameters.The above function i used it as notifyJS

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift