开发者

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.

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

<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:123456789开发者_JAVA百科0">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;


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜