Search code examples
iphonehrefmailto

mailto: link in UIWebView - Does Not work


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?


Solution

  • 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;
    }