gpt4 book ai didi

cordova - 电话间隙 : Trying to pre populate email sent with Email Composer

转载 作者:行者123 更新时间:2023-12-02 07:53:50 25 4
gpt4 key购买 nike

我一直在寻找这个问题的答案。我已经下载并成功安装了 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;

这发生在页面首次加载时。

关于我在这里做错了什么有什么想法吗?

最佳答案

(OP 在问题编辑中回答。已移至社区 wiki 答案。请参阅 Question with no answers, but issue solved in the comments (or extended in chat) )

OP 写道:

I figured it out! The solution was relatively easy, but for the life of me, I couldn't get it for the first couple of hours.

In your HTML code, wherever your button is, put this:

<a onclick="sendEmail(); return false;">Send Email Now</a>

that sendEmail() function is where the business is, so on the same page, create a script tag and add the following:

<script>
function sendEmail(){
window.plugins.emailComposer.showEmailComposer("subject","body", "recipient@something.com", "cc@something.com", "bcc@something.com",false);
}
</script>

In the same HTML after your app has been initialized, just add the args variable:

app.initialize(); //under this
var args = {};

Keep the EmailComposer.js file the same and all should be well. In search of this answer, I ran across a ton of posts where people could pass the subject line, but couldn't pass the body or anything else. I tested it out, and this will pass all field properly. I hope this helps someone.

关于cordova - 电话间隙 : Trying to pre populate email sent with Email Composer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13751998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com