javascript - Uncaught ReferenceError: require is not defined -


i trying implement cordova-plugin-email-composer.i installed plugin using cli

cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git

i got error uncaught referenceerror: require not defined @ email_composer.js:22.

in link u can find plugin. added code attached below in index.js file. can solve this? thankyou.

index.js:

bindevents: function() {     document.addeventlistener('deviceready', this.ondeviceready, function () {         cordova.plugins.email.isavailable(             function (isavailable) {                 alert("is email mobile available? " + (isavailable ? "yes" : "no"));                 if(isavailable){                  window.plugin.email.open({                      to:      'anu.barbie143@gmail.com',                      subject: 'greetings',                      body:    'how you? nice greetings leipzig'                  }, callback, scope);                }             }         );     }, false);      function callback(){         console.log("callback function");     }      function scope(){         console.log("scope function");     }  }, 

email_composer.js:

var exec      = require('cordova/exec'), isandroid = navigator.useragent.tolowercase().indexof('android') > -1, mailto    = 'mailto:'; 

in above code got error require not defined.can me solve this? thankyou.

i made work doing following

cordova plugin rm cordova-plugin-email-composer 

then add plugin version 0.8.2,by following command since there open error in plugin version 0.8.3 loolipop

cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git#0.8.2 

index.js

var app = {     // application constructor     initialize: function() {         document.addeventlistener('deviceready', this.ondeviceready.bind(this), false);     },      // deviceready event handler     //     // bind cordova events here. common events are:     // 'pause', 'resume', etc.     ondeviceready: function() {         this.receivedevent('deviceready');                  cordova.plugins.email.open({                     to:      'test@gmail.com',                     cc:      'test@gmail.com',                     bcc:     [],                     subject: 'greetings',                     body:    'how you? nice greetings naresh'                 });        },      // update dom on received event     receivedevent: function(id) {         var parentelement = document.getelementbyid(id);         var listeningelement = parentelement.queryselector('.listening');         var receivedelement = parentelement.queryselector('.received');          listeningelement.setattribute('style', 'display:none;');         receivedelement.setattribute('style', 'display:block;');          console.log('received event: ' + id);     } };  app.initialize(); 

hope helps you..


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -