を使用してiOSの中で発射することはありません。私のテストのコルドバfilePluginIsReadyイベントは、私は数週間のために永続的なデータを扱うデバッグしてきた...と私は私が最終的に問題の*一部を発見したと思うコルドバ・プラグイン・ファイル
ほとんどは、Windows 10上でクロム59でブラウザのプラットフォームを実行しているが、私はまた、PhoneGapのと私のアプリのビルドを構築し、私のiPhone(iOS版10.3.2)にインストールしています。 Cordova doc's Chrome querksによると
:
Chrome filesystem is not immediately ready after device ready event. As a workaround you can subscribe to filePluginIsReady event. Example:
window.addEventListener('filePluginIsReady', function(){ console.log('File plugin is ready');}, false);
You can use
window.isFilePluginReadyRaised
function to check whether event was already raised.
私は「filePluginIsReady」イベントリスナーの作業を取得することができませんでしたので、最終的にはwindow.isFilePluginReadyRaised
をconsole.logging試みたが、案の定、それは偽です!絶望の問題として
setTimeout(function(){
console.log('filePluginIsReady: ' + window.isFilePluginReadyRaised());
consol.append(document.createElement("br"));
consol.append('filePluginIsReady: ', window.isFilePluginReadyRaised());
}, 5000);
を追加しようと、私は本当入手します!私はそれを1000msまで下げようとしましたが、それでも動作しますが、タイムアウトがなければ、私は間違っています。私は美しい緑の「デバイスの準備ができている」を取得...私は何を取得
を、しかし後:私は、私は自分の携帯電話上でこれをデバッグすることができますので、問題に私をもたらした、DOM要素にコンソールログを追加しています5秒間、私の「コンソール」は空白のままです。私は私のファイル構造が間違っていたことを発見し :window.isFilePluginReadyRaised()
マイHTML
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
<h3>Console:</h3>
<pre id='consol'></pre>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="dist/build.js"></script>
JS
var app = {
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
onDeviceReady: function() {
this.receivedEvent('deviceready');
setTimeout(function(){
console.log(cordova.file);
console.log('filePluginIsReady: ' + window.isFilePluginReadyRaised());
consol.append(document.createElement("br"));
consol.append('filePluginIsReady: ', window.isFilePluginReadyRaised());
}, 5000);
},
receivedEvent: function (id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
},
};
app.initialize();
config.xmlの
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<preference name="iosPersistentFileLocation" value="Library" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="browser" spec="^4.1.0" />
<plugin name="cordova-plugin-file" spec="^4.3.3" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
</widget>
編集から何の結果はありません。 Phonegapは、configがwwwディレクトリになければならないと指定しますが、私の場合はレベルアップです。これを修正しても問題は解決されませんでした。私はまた、PhoneGapのログを構築するにチェック:少し近い質問を読んだ後
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "[email protected]^4.3.3" via npm
Installing "cordova-plugin-file" at "4.3.3" for ios
Fetching plugin "cordova-plugin-compat" via npm
Installing "cordova-plugin-compat" at "1.1.0" for ios
Fetching plugin "[email protected]^1.3.2" via npm
Installing "cordova-plugin-whitelist" at "1.3.2" for ios
ありがとう:
は、HTMLのbodyタグの「onloadイベント」メソッドに取り付ける、できるだけ早く両方の「filePluginIsReady」と「deviceready」イベントを登録してみてください。私のオリジナルの答えビットを微調整するために、返信のために、私は 'Uncaught ReferenceError:app is defined'を避けるにはどうすればいいですか? – Chase
私の答えを更新しました。これを試してみてください。プラグインは、正直なところ、扱いにくい場合があります。全く異なる問題があるかもしれません。 http://phonegap-tips.com/articles/debugging-ios-phonegap-apps-with-safaris-web-inspector.html – dotNetkow
それでものみonDeviceReadyは、ログインしてご覧ください(Windowsの10/FF&:また、お使いのMacとiPhone使ってデバッグしてみてくださいクロム)。私はWindows上にいるので、iOSのデバッグオプションは限られています。しかし、コンソールログを偽造するためにdom要素に何かを注入するという私のやり方でも、deviceReadyは起動しますが、filePluginReadyは起動しません。あなたはそうだ、プラグインが難しいと思われる...私はスーパー縮小テストで作業しようとしていましたが、他の誰かが私がdeviceReadyで作業するために使用しているデータハンドラを持っていました。だから私はファイルプラグインが準備ができていると思っても、私はそれをテストすることはできません...だからこれはもはや優先順位ではなく、まだに関する:(それに刺すように感謝! – Chase