Open Mail.app on IPhone from webpage that's INSIDE an app

1.8k views Asked by At

our app loads profile pages from our website INSIDE the app. They have been optimized for iPhone css, but they are still an html page. Our mailto link isnt working as expected. When clicked, nothing happens. However, when clicked and held (tap and hold), the menu slides up with "new message", "create new contact", "copy", etc.

How should this be formatted to get the Mail.app to automatically launch?

<a class="action_bubble" target="_blank" rel="external" href="mailto:[email protected]">Send Email</a>

The "call" link works as expected.

<a class="action_bubble" href="tel:1234567890">Call</a>

So, not sure what to do with this...

4

There are 4 answers

0
Walter On BEST ANSWER

Here is a project on GitHub that addresses your issue. Basically, when you use a UIWebView controller, you need to decide how to manage the links using the delegate handler for UIWebView. In Interface Builder you can have it automatically recognize phone numbers which is probably why your phone numbers work and it will recognize http links as default behavior. However, mailto and some of the other special href options will need to be handled manually.

1
Nnp On

make sure "Detection" property is set for your UIWebView like "Phone","Address". you can set it from your IB.

or from code

self.webView.dataDetectorTypes = UIDataDetectorTypeAll;

3
Nick Weaver On

Could it be, that you have just tried within the simulator? The simulator does not have a mail app, so it couldn't be opened. Try on a device. I think your code actually works.

I've just tested on a device: your code works.

0
Herc On

A little late to the party but I've found out the following:

  1. iOS has some weird ways to deal with web content
  2. DON'T encapsulate your email address within an A tag, just put it there as plain text
  3. Make sure that in your storyboard (if using one) the webView has the Addresses property checked and you're done ... same goes for phone numbers