title: How to call Objective-C from Javascript?
body: <p>I have a WebView, and I want to call a view in Objective-C from JavaScript. Does someone know how I can do this?</p>
  
  <hr>
  
  <p>I have this code in my ViewController:</p>
  
  <pre><code>- (BOOL)webView:(UIWebView *)webView2 
   shouldStartLoadWithRequest:(NSURLRequest *)request 
   navigationType:(UIWebViewNavigationType)navigationType {
  
   NSString *requestString = [[request URL] absoluteString];
   NSArray *components = [requestString componentsSeparatedByString:@":"];
  
   if ([components count] &gt; 1 &amp;&amp; 
    [(NSString *)[components objectAtIndex:0] isEqualToString:@"myapp"]) {
    if([(NSString *)[components objectAtIndex:1] isEqualToString:@"myfunction"]) 
    {
  
     NSLog([components objectAtIndex:2]); [[Airship shared] displayStoreFront]; //&lt;- This is the code to open the Store
     NSLog([components objectAtIndex:3]); // param2
     // Call your method in Objective-C method using the above...
    }
    return NO;
   }
  
   return YES; // Return YES to make sure regular navigation works as expected.
  }
  </code></pre>
  
  <p>And in Javascript:</p>
  
  <pre class="lang-js prettyprint-override"><code>function store(event)
  {
      document.location = "myapp:" + "myfunction:" + param1 + ":" + param2;
  }
  </code></pre>
  
  <p>But nothing happens.</p>