Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios PhoneGap-由于页面加载而重置插件_Ios_Cordova_Phonegap Plugins - Fatal编程技术网

Ios PhoneGap-由于页面加载而重置插件

Ios PhoneGap-由于页面加载而重置插件,ios,cordova,phonegap-plugins,Ios,Cordova,Phonegap Plugins,在集成本地EmailComposer时,我在phonegap中遇到了一个问题 MailComposer应该在单击按钮时打开,但它不会显示IOS的MailComposer,android的相同代码正在工作 我的代码如下: <html> <head> <script type="text/javascript" charset="utf-8" src="cordova.js"></script>

在集成本地EmailComposer时,我在phonegap中遇到了一个问题

MailComposer应该在单击按钮时打开,但它不会显示IOS的MailComposer,android的相同代码正在工作

我的代码如下:

        <html>
        <head>
            <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
            <script type="text/javascript" charset="utf-8" src="emailcomposer.js"></script>

            <script type="text/javascript">
            document.addEventListener("deviceready", deviceready, true);
            function deviceready() {
                console.log("Device ready");
            }.
            //function to send mail using mail composer
            function composeText(){
var vehiclemileage = document.getElementById('vehiclemileage').value;
var vehiclemodel = document.getElementById('vehiclemodel').value;
var message1 = document.getElementById('message_body').value;
var vechicleyear = document.getElementById("yeardropdown");
var strUser = vechicleyear.options[vechicleyear.selectedIndex].value;
var vehiclemake = document.getElementById("vehiclemake");
var makevehicle = vehiclemake.options[vehiclemake.selectedIndex].value;

var deviceName = device.platform;
var devicemodel = device.model;


if(vehiclemodel == '' || makevehicle == ''){
alert("Please Enter all the Value");

 navigator.notification.alert(
        'Please Enter all the Value', // message
        alertDismissed,              // callback
        'Vehicle and Model',        // title
        'Ok'                       // buttonName
    );
 }
else
{
            //function to check folder named "RepairMyCar" and extract picture from folder to attach it to mail
                var attachPath; 
                var attachFile= new Array();
                window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
                    fileSystem.root.getDirectory("RepairMyCar", {
                        create: true
                    }, 
        function(directory) {
            console.log("Final 63" + directory.fullPath);
            attachPaths = directory.fullPath;
            var attachPath=attachPaths.slice(7,attachPaths.length);
            var directoryReader = directory.createReader();
            directoryReader.readEntries(function(entries) {
                var i;
                for (i=0; i<entries.length; i++) {
                    console.log(entries[i].name);
attachFile[i] =attachPath + "/" + entries[i].name;
                            }
                            console.log(attachFile);
                        }, 
                        function (error) {
                            alert(error.code);
                        });

                    });
                }, function(error) {
                    alert("can't even get the file system: " + error.code);
                });
                var dated, fnamed, phoned, emailed;
                 if(typeof(Storage)!=="undefined")
{
 dated = localStorage.date;
 fnamed = localStorage.fname;
 phoned = localStorage.phone;
 emailed= localStorage.email;
}

                console.log(attachFile);
                var newattachment = attachFile.toString();
                //Open mail composer with all datas
 setTimeout(function(){window.plugins.emailComposer.showEmailComposerWithCallback(null,
                    "Get an Estimate",
                     "Date: " + dated + '<br>' + "First Name: " + fnamed +  '<br>' + "Phone Number: " + phoned +  '<br>' + "Email Address: " + emailed +   '<br>' + "Year of Vehicle: " + strUser +  '<br>' + "Make of Vehicle: " + makevehicle +  '<br>' +  "Model of Vehicle: " + " " + vehiclemodel + '<br>' + 
                     "Mileage of Vehicle: " + " " + vehiclemileage + '<br>' +  message1 + '<br>' + "Sent from My:" + deviceName + devicemodel,
                [sth@sth.com],
                    [],
                    [],
                    true,
                    attachFile
                    );},100);
                //Clear LoccalStorage
                localStorage.clear();
            //exit the app after clicking this button
            navigator.app.exitApp();
            // navigator.camera.cleanup(onSuccess,fail);
            // function onSuccess(){
            // }
            // function fail(){
            // }
        }
}
        function onFail(message) {
            alert('Failed because: ' + message);
        }

    /***********************************************
    * Drop Down Date select script- by JavaScriptKit.com
    * This notice MUST stay intact for use
    * Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
    ***********************************************/
    //function to  load year in drodown. Default selected year : Current Year
    function populatedropdown(yearfield){
        var today=new Date()
        var yearfield=document.getElementById(yearfield)
        for (var i=0; i<31; i++)
            //Select Year
    var thisyear=today.getFullYear()
    for (var y=0; y<25; y++){
        yearfield.options[y]=new Option(thisyear, thisyear)
        thisyear-=1
    }
    yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
    }
    </script>

    </head>
    <body>
        <div class="wrapper">
            <h1>Get a Repair Estimate</h1>
            <div class="main-content">
    <p>
                Please Enter the Year, Make, Model and Mileage of Your Vehicle and any other information we should know.
                </p>
                <form class="vehicle-detail-form">
                <ul>
                    <li>
                        <label>Year of Vehicle: </label>
                        <form action="" name="someform">
                        <select id="yeardropdown">
                        </select> 
                    </form>

                    <script type="text/javascript">

    //populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
    window.onload=function(){
        populatedropdown("yeardropdown")
    }
    </script>
                    </li>
                    <!-- Vehicle Year Selection -->

    <li><label>Model of Vehicle:</label>
    <input type="text" name="vehiclemodel" id = "vehiclemodel">
    </li>
    <li><label>Mileage of Vehicle:</label>
    <input type="number" name="vehiclemileage" id = "vehiclemileage"></li>
    <li>
        <textarea  name="message_body" id = 'message_body'  placeholder="Add Notes here(if any)"></textarea>
    </li>
    </form>
    <div style="clear:both;"></div>
    <div class="large-button-wrapper">
    <button onclick="composeText();">Get Your Estimate</button>
    </div>  
    </div>
    </div>
    </body>
    </html>

文件。添加的监听器(“DeviceRady”,DeviceRady,true);
函数devicerady(){
控制台日志(“设备就绪”);
}.
//使用mail composer发送邮件的函数
函数composeText(){
var vehiclemileage=document.getElementById('vehiclemileage')。值;
var vehiclemodel=document.getElementById('vehiclemodel').value;
var message1=document.getElementById('message_body')。值;
var vechicleyear=document.getElementById(“yeardropdown”);
var strUser=vechicleyear.options[vechicleyear.selectedIndex].value;
var vehiclemake=document.getElementById(“vehiclemake”);
var makevehicle=vehiclemake.options[vehiclemake.selectedIndex].value;
var deviceName=device.platform;
var devicemodel=设备.model;
如果(车辆模型=“”| | makevehicle=“”){
警报(“请输入所有值”);
navigator.notification.alert(
'请输入所有值',//消息
AlertDisabled,//回调
“车辆和型号”,//标题
“好的”//buttonName
);
}
其他的
{
//此函数用于检查名为“RepairMyCar”的文件夹,并从文件夹中提取图片以将其附加到邮件中
var attachPath;
var attachFile=新数组();
requestFileSystem(LocalFileSystem.PERSISTENT,0,函数(fileSystem){
fileSystem.root.getDirectory(“RepairMyCar”{
创建:true
}, 
功能(目录){
log(“Final 63”+directory.fullPath);
attachPaths=directory.fullPath;
var attachPath=attachPath.slice(7,attachPath.length);
var directoryReader=directory.createReader();
directoryReader.readEntries(函数(条目){
var i;

对于(i=0;i如果你在iOS项目上工作,我发现了一个解决方法。我也有同样的问题

主干路由器
控制台.log
中的视图更改后,在Xcode中停止工作后,您可以在Mac上使用Safari Web Inspector。每个
控制台.log
都在那里可见