user2335065
user2335065

Reputation: 2557

Is there a way to trigger the native ios share function from a ios webview?

is there a way to trigger the native ios share function from a ios webview?

On Android I'm doing this by using JavaScript Interface and call the share intent. I am wondering can I do the same for my ios app.

Upvotes: 3

Views: 1047

Answers (1)

arturdev
arturdev

Reputation: 11039

Check UIWebViewDelegate method named
-webView:shouldStartLoadWithRequest:navigationType:. e.g.

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
   if ([[request.URL absoluteString] isEqualToString:@"share_url"]) { 
       // Open native share dialog
       return NO;
   }
   return YES;
}

Upvotes: 1

Related Questions