0

I want to use my existing angularjs functionality in my ios app. I will be sending data from Obj C to angularjs, angular will check if the data is correct, and then send back a response "ok" to Obj C.

When Obj C receives the response "ok", it will load the second view controller.

For some reason it seems like

-(void)webViewDidStartLoad:(UIWebView *)webView

- (void)webViewDidFinishLoad:(UIWebView *)webView 

and

- (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

are not by my side.. I will have to go back and forth between Obj C and AngularJS.

Any help would be really appreciated. If you have code samples and links, please do post it.

Thanks

Swift
  • 397
  • 1
  • 2
  • 11
  • I am afraid that the `- (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType` is the only way i know with which u can call obj-c from javascript. What is the reason for not being able to use this method? – MMhunter Jul 05 '16 at 09:17
  • After passing the parameters through `webViewDidFinishLoad`,even the sample alert in my js is not getting fired – Swift Jul 05 '16 at 09:20
  • I am not sure but i am assuming that u are trying to run js code with `- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script` in `webViewDidFinishLoad`? – MMhunter Jul 05 '16 at 09:41
  • Yes.. I am calling my js function there and passing the parameters – Swift Jul 05 '16 at 09:55
  • Then i believe simple js like `webView stringByEvaluatingJavaScriptFromString:@"alert('ok')"]` should work. The problem could be that ur function is not in the window's scope. [This question](http://stackoverflow.com/questions/22407062/call-javascript-function-from-ios-webview-in-angularjs-app) may have a little help – MMhunter Jul 05 '16 at 10:02

0 Answers0