mailto: link in UIWebView - Does Not work

Sean McCully picture Sean McCully · Apr 5, 2010 · Viewed 18k times · Source

Is the areanything special you need in html or Callbacks in a UIWebView to handle anchor tags with an href, or is there something special about an anchor tag with a mailto link in the href?

Answer

cduhn picture cduhn · Apr 6, 2010

In your UIWebView's delegate, do:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if ([[[request URL] scheme] isEqual:@"mailto"]) {
        [[UIApplication sharedApplication] openURL:[request URL]];
        return NO;
    }
    return YES;
}