简体   繁体   中英

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

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.

<a class="action_bubble" target="_blank" rel="external" href="mailto:bob@bob.com">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...

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.

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;

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM