Breaking News
Home / iOS / iOS Snippets / UIWebView does not launch mail when mailto href is clicked

UIWebView does not launch mail when mailto href is clicked

Answer

By default the UIWebView only responds or loads http protocol related URI. For the webview to respond to mailto URI, add the following code as implementation of shouldStartLoadWithRequest method to the UIWebViewDelegate.

  1. (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
  2.     if ([[[request URL] scheme] isEqual:@"mailto"]) {
  3.         [[UIApplication sharedApplication] openURL:[request URL]];
  4.         return NO;
  5.     }
  6.     return YES;
  7. }
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger