我一直在寻找这个问题的答案。我已经下载并成功安装了 PhoneGap 的 EmailComposer 插件。我可以点击我的“电子邮件”按钮,电子邮件字段在那里弹出没有问题。问题是,我正在尝试预先填充“收件人:”字段和“主题”字段。我搜索了各种帖子(主要是在 StackOverflow 上)并且我看到了一些类似的帖子,但没有任何与这个完全相同的问题或真正的解决方案有关的帖子:
我试过的帖子: PhoneGap Email Composer Plugin How to send email using mail composer plugin in iphone using phone gap jQuery mobile
我能找到的最接近的是: https ://groups.google.com/forum/#!searchin/phonegap/EmailComposer/phonegap/ItUj30UZnig/XTaBK7B8ahsJ
但我对那里的解决方案没有任何运气。
正如刚才提到的。我要做的就是预先填充“收件人:”和“主题:”字段。包含的 EmailComposer.js 文档如下所示:
// window.plugins.emailComposer
function EmailComposer() {
this.resultCallback = null; // Function
}
EmailComposer.ComposeResultType = {
Cancelled:0,
Saved:1,
Sent:2,
Failed:3,
NotSent:4
}
// showEmailComposer : all args optional
EmailComposer.prototype.showEmailComposer = function(subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML) {
var args = {};
if(toRecipients)
args.toRecipients = toRecipients;
if(ccRecipients)
args.ccRecipients = ccRecipients;
if(bccRecipients)
args.bccRecipients = bccRecipients;
if(subject)
args.subject = subject;
if(body)
args.body = body;
if(bIsHTML)
args.bIsHTML = bIsHTML;
cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
}
// this will be forever known as the orch-func -jm
EmailComposer.prototype.showEmailComposerWithCB = function(cbFunction,subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML) {
alert("email showEmailComposerWithCB?");
this.resultCallback = cbFunction;
this.showEmailComposer.apply(this, [subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML]);
}
EmailComposer.prototype._didFinishWithResult = function(res) {
this.resultCallback(res);
}
cordova.addConstructor(
function() {
if(!window.plugins) {
window.plugins = {};
}
// shim to work in 1.5 and 1.6
if (!window.Cordova) {
window.Cordova = cordova;
};
//window.plugins.emailComposer.showEmailComposer(subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML)
window.plugins.emailComposer = new EmailComposer();
}
);
以以下开头的实际行:
EmailComposer.prototype.showEmailComposer
从未真正被解雇。在面向公众的方面,我有这个(它是有效的 HTML,但我删除了一些标签以用于发布目的:
<a onclick="cordova.exec(null, null, 'EmailComposer', 'showEmailComposer', [args]);">Send Email</a>
然后我有:
app.initialize();
var args;
当页面首次加载时会发生这种情况。
关于我在这里做错了什么的任何想法?