Emailcomposer Cordova no Angularjs

Asked

Viewed 40 times

1

I was reading a project in the email plugin github of Cordova and did not understand how to install.
It gives you the option to download the files, and then asks you to put this line in xml.

<gap:plugin name="cordova-plugin-email-composer" />

Only then, what do I have to do? put Composer.js inside the js file folder? and the folders of android devices, Ios and W8, where to go? Can someone help me ?
The source comes from here: https://github.com/katzer/cordova-plugin-email-composer#open-a-pre-filled-email-draft

1 answer

0

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

  • appeared, Cordova is not defined

  • 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)

  • using phonegap on mobile and downloading the project I can see if the email opens?

  • using phonegap, it only enters the if of window.cordova. <br /> in other ifs, I believe that will only enter, if buildar.

  • Yes, if buildar will work properly.

  • 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.

  • Strange. And if you add the line in xml, it works correctly?

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.