简体   繁体   中英

Cordova - Open native email app from button click

When writing a native IOS app for example, you can open the native "Mail" app from a button click within an app. The email will come up pre-filled with certain data (send-to address, subject, body, etc.).

How can I simulate this across all devices using HTML5/Javascript in my cordova app?

Using HTML5, you can do this with an anchor tag in your .html file. Here is an example:

<a href="mailto:email@gmail.com?subject=Example Subject 
&body=Thanks for the help!">Send an email</a>

This will work across all devices and resort to native functionality to handle the email task.

另外,从cordova 3.6.3开始,您还需要在config.xml中包含以下权限。

<access origin="mailto:*" launch-external="yes"/>

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