pixelbitlabs
pixelbitlabs

Reputation: 1934

Detect a mail link and when pressed, mail the address in app

How can I detect when a mailto link is pressed in a UIWebView, and when it is pressed, open a window in the app to send the mail.

Upvotes: 1

Views: 2323

Answers (2)

Narayana Rao Routhu
Narayana Rao Routhu

Reputation: 6323

implement below method

- (BOOL)webView:(UIWebView *)webView1 shouldStartLoadWithRequest:(NSURLRequest *)request  navigationType:(UIWebViewNavigationType)navigationType{
    NSURL *requestURL = [request URL];  
    NSString *str_url = [requestURL absoluteString];
    if([str_url isEqualToString:@"about:blank"]){
        return YES;
    } else {
        //you can write  mailComposeController methods over here
    }
}

Upvotes: 1

Ankit Srivastava
Ankit Srivastava

Reputation: 12405

you can set the webview to recognize the links as

webView.dataDetectorTypes=UIDataDetectorTypeLink;

here is a link which will be of help I guess...

http://www.iphonedevsdk.com/forum/iphone-sdk-development/21630-open-email-editor-href-link-uiwebview.html

Upvotes: 1

Related Questions