带有附件的电子邮件编辑器Phonegap插件在iOS中不能与imageURI一起工作

Email composer with attachments Phonegap plugin not working with imageURI in iOS

本文关键字:不能 iOS imageURI 工作 一起 插件 电子邮件 Phonegap 编辑器      更新时间:2023-09-26

我试图从我的phonegap应用程序发送图片作为附件使用电子邮件作曲家与附件电话差距插件。但是我不能让它工作。

我已经尝试了两种不同的方法。第一种是使用Phonegap相机api将imageURI传递给email composer。代码如下:

function camera1()
        {
            navigator.camera.getPicture(sendEmail, onFail, { quality: 20,
                                        destinationType: Camera.DestinationType.FILE_URI});
            function sendEmail(imageURI) {
                window.plugins.emailComposer.showEmailComposer("Test","Test","test@gmail.com","","",true,imageURI)
            }
            function onFail(message) {
                alert('Failed because: ' + message);
            }
        }

这个方法启动iphone相机应用程序,允许我拍照。然而,只要我点击"使用"按钮,我得到以下错误在我的xcode调试控制台:

2013-01-06 17:57:50.741 Saffron Housing Mobile App[1203:907] -[_NSCFString countByEnumeratingWithState:objects:count]:无法识别的选择器发送到实例0x1dd9d6a02013-01-06 17:57:50.906藏红花住房移动应用程序[1203:907]EmailComposer -不能设置收件人;error: -[_NSCFString countByEnumeratingWithState:objects:count:]:无法识别的选择器发送到实例0x1dd9d6a02013-01-06 17:57:50.914 Saffron Housing Mobile App[1203:907] -[_NSCFString countByEnumeratingWithState:objects:count:]:无法识别的选择器发送到实例0x1dd1abf02013-01-06 17:57:50.916藏红花住房移动应用程序[1203:907]EmailComposer -不能设置附件;error: -[_NSCFString countByEnumeratingWithState:objects:count:]:无法识别的选择器发送到实例0x1dd1abf02013-01-06 17:57:51.524 Saffron Housing移动应用程序[1203:907]警告:尝试在演示文稿正在进行时进行演示!

我尝试使用的第二种方法是将图像保存到本地存储,然后将其作为变量传递给email composer。我还在此方法中实现了一个通知事件,因为之前的错误消息使我认为电子邮件作曲家插件在相机事件后试图打开得太快(纯粹的猜测基于"警告:试图在演示文稿正在进行时呈现!")代码如下:

function camera1()
        {
            navigator.camera.getPicture(sendAlert, onFail, { quality: 20,
                                        destinationType: Camera.DestinationType.FILE_URI});
                                        localStorage.setItem('photo', imageURI);
            function sendAlert()
                navigator.notification.confirm('Send Picture?',sendEmail,'Send Picture?','Yes,No')
            function sendEmail(1) {
                var photo = localStorage.getItem('photo')
                window.plugins.emailComposer.showEmailComposer("Test","Test","test@gmail.com","","",true,photo);
            }
            function onFail(message) {
                alert('Failed because: ' + message);
            }
        }

这段代码的问题是相机根本没有启动。当我点击按钮时,什么也没发生。甚至调试控制台中也没有任何内容。

为了进一步使事情复杂化,我试着打开一个基本的电子邮件作曲家事件,看看我已经正确地实现了插件。当没有附上图片时,电子邮件编写者至少打开了我的主题和主体。但它没有填写任何收件人。代码是:

function camera()
        {
            window.plugins.emailComposer.showEmailComposer("Test","Test","test@gmail.com","","",true,"")
        }

我的问题是我做错了什么?

toRecipients, ccRecipients, bccRecipientsattachments参数应该是数组,但是您将它们作为字符串传递。

window.plugins.emailComposer.showEmailComposer("Test", "Test", ["test@gmail.com"], [], [], true, [imageURI]);

我不知道这是否是你的错误的原因,但你的附件的路径应该有点像["/var/mobile/Applications/351............F3/yourapp.app/www/images/yourrimage .png"]