I am consuming html json data in my iOS app. HTML response has few div blocks with onClick methods. When I tap on these blocks I invoke some javascript code in web view, but I need also know about these events in my source code.
For example when I tap on web element and onClick is called I need to invoke some method in the code .
- (void)patientResponse:(UIWebView *)webView modeDict:(NSDictionary *)modeDict
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString *protocolPrefix = EVENT;
NSString *urlStr = [[request URL].absoluteString substringFromIndex:protocolPrefix.length];
urlStr = [urlStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSError *jsonError;
NSDictionary *callInfo = [NSJSONSerialization
JSONObjectWithData:[urlStr dataUsingEncoding:NSUTF8StringEncoding]
options:kNilOptions error:&jsonError];
if([[callInfo valueForKey:@"acton"] isEqualToString:Set_id])
[self patientResponse:webView modeDict:callInfo];
return NO;
}
- (void)patientResponse:(UIWebView *)webView modeDict:(NSDictionary *)modeDict
{
NSString *mode = [[modeDict valueForKey:@"params"] valueForKey:@"PatientName"];
self.patientName = mode;
NSLog(@"Patient name is:%@",self.patientName);
}