First you have to install it, the way plugins are installed by default on Cordova:
cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git
Then you check in your code if Cordova is enabled (not to give error when you are viewing in the pc browser).
And then you use the isAvaible and open methods of the plugin in question
Would something like this:
document.addEventListener('deviceready', function () {
if(window.cordova){
sendMail('teste', "[email protected]", "E aí fulano maluco, continua insano?");
}
}, false);
function sendMail(assunto, paraQuem, corpoDoEmail){
cordova.plugins.email.isAvailable(
function (isAvailable) {
if(!isAvailable){
return window.alert("Nao pode enviar email");
}
cordova.plugins.email.open({
to: paraQuem,
subject: assunto,
body: corpoDoEmail
});
}
);
}
That part of <gap:plugin name="cordova-plugin-email-composer" />
is automatically inserted with the Cordova plugin add command I mentioned above. If you want to open a blank draft without the filled dice, simply call the open without passing any parameter:
cordova.plugins.email.open();
question, do I install Cordova in the www folder, or the folder before it? , another question, where I check to see if Cordova was actually installing, because at least the plugins folder appeared here
– Michel Henriq
appeared, Cordova is not defined
– Michel Henriq
your Ordova is already installed, phonegap is installed by it. You can run the calling from anywhere in your project. You must use if (window.Cordova). Cordova will only be set after you build the smartphone, you can’t use the Cordova plugins in the browser. (I changed the code)
– LF Ziron
using phonegap on mobile and downloading the project I can see if the email opens?
– Michel Henriq
using phonegap, it only enters the if of window.cordova. <br /> in other ifs, I believe that will only enter, if buildar.
– Michel Henriq
Yes, if buildar will work properly.
– LF Ziron
i install the plugin via cmd, but that line on the plugin does not appear in xml, so when I build it does not install this plugin.
– Michel Henriq
Strange. And if you add the line in xml, it works correctly?
– LF Ziron