I am currently facing an issue with my dashboard.html page and DashboardController.js in relation to UIWebview. I am attempting to call an AngularJS function from DashboardController.js within the UIWebview, but it seems to not be working.
Below is the code snippet that I have been trying on iOS:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = [request URL];
NSLog(@"URL:%@",url);
if (![Utility isInternetAvailable]) {
return FALSE;
}
NSString *jsCallBack = [NSString stringWithFormat:@"DashboardController.test()"];
NSString *response = [webView stringByEvaluatingJavaScriptFromString:jsCallBack];
NSLog(@"%@",response);
return YES; // Return YES to ensure regular navigation functions as expected.
}
I also attempted without referencing the Controller after confirming that dashboard.html has loaded inside the UIWebview: NSString *jsCallBack = [NSString stringWithFormat@"test()"];
The test() function is defined within the scope of DashboardController.js:
function test (){
alert('sendCredentialsToNativeApp');
}
Any help would be greatly appreciated. Thank you.