我正致力于cordova
电子邮件作曲家发送电子邮件。但是当我尝试执行应用程序时,我收到错误"email plugin not available"
。
当我添加
< gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.2" />
到配置文件我收到错误。这是我的代码。
<!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>
配置文件:
<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>
答案 0 :(得分:0)
在draftEmail中,您正在检查cordova.plugin但不检查cordova.plugins,因此您收到错误警告。
交叉回答您的交叉帖子:)