1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

e-mail not working

Discussion in 'JavaScript' started by kadi, Dec 23, 2014.

  1. #1
    I am working on cordova email composer to send emails. But I am getting the error "email plugin not available" . when I tried to execute the app I am getting the above said error. i'm building locally on my laptop using android emulator. Here is my code.

    
    <!DOCTYPE html>
    <html>
      <head>
        <title>Contact Example</title>
    
        <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
        <script type="text/javascript" charset="utf-8">
    document.addEventListener("deviceready", onDeviceReady, false);
    
        // Cordova is ready
        //
        function onDeviceReady() {
            // specify contact search criteria
            var options = new ContactFindOptions();
            options.filter="";          // empty search string returns all contacts
            options.multiple=true;      // return multiple results
            filter = ["displayName"];   // return contact.displayName field
    
            // find contacts
            navigator.contacts.pickContact(function(contact){
            console.log("The following contact has been selected:" + JSON.stringify(contact));
        },function(err){
            console.log("Error: " + err);
        });
    }
    
        // onSuccess: Get a snapshot of the current contacts
        //
        function onSuccess(contacts) {
            for (var i=0; i<contacts.length; i++) {
                alert(contacts[i].displayName);
            }
        };
    
        // onError: Failed to get the contacts
        //
        function onError(contactError) {
            alert("onError!");
        };
    document.addEventListener("deviceready", draftEmail, false);
    function draftEmail(subject, message) {
        if (!cordova.plugin){
            //non-mobile - plugins are not present.
            alert("Email plugin is not available");  
            return;
        }
        if (!isAvailable){
            //mobile, but no email installed
            alert("Email is not available")
            return;
        }
    cordova.plugins.email.addAlias('gmail', 'com.google.android.gm');
        cordova.plugins.email.open({
            app: 'gmail',
        subject: 'Sent from Gmail',
            body: 'How are you?',
            isHtml: true
        })
    }
    
      </script>
      </head>
      <body>
    
      </body>
    </html>
    Config file:
    
    <feature name="EmailComposer"> <param name="android-package" value="de.appplant.cordova.plugin.emailComposer.EmailComposer" /> </feature> 
    <feature><gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.0" /></feature>
    </widget>
    Code (markup):

     
    kadi, Dec 23, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Don't know Cordova, but might it be that the Android Emulator doesn't really behave like android and therefore reacts like a laptop (ie, no email available)?
    Try to run it off an actual android-phone?
     
    PoPSiCLe, Dec 23, 2014 IP