徹底的頭腦風暴後,我找到了答案 -
我的問題是,文件傳輸對象可以從platform ready
函數內部,但不是provider
內訪問 - 這也對的iOS [Android版本工作正常]
這裏是我做過什麼:
因爲我需要provider
內FileTransfer
的實例 - 我創建了一個變量 - 和更新方法 -
private fileTransfer: any;
public setFileTransferRef(param){
this.fileTransfer = param;
}
正如我可以訪問FileTransfer
的platform.ready()
裏面 - 我實例化的FileTransferObject
在那裏,並更新了provider
如下 -
initializeApp() {
this.platform.ready().then(() => {
console.log('fileTransfer: ');
console.log(JSON.stringify(this.fileTransfer));
//
let fileTransfer: FileTransferObject = this.fileTransfer.create();
//
this.mediaIOSProv.setFileTransferRef(fileTransfer);
.....
....
我也放在與cordova.js
列入build/vendor.js
後的index.html
- (我碰到一些帖子,開發人員報告說,這樣做解決了他們失蹤的插件的問題) - 雖然沒有這樣的官方文檔。
<body>
<!-- Ionic's root component and where the app will load -->
<ion-app></ion-app>
<!-- The polyfills js is generated during the build process -->
<script src="build/polyfills.js"></script>
<!-- The vendor js is generated during the build process
It contains all of the dependencies in node_modules -->
<script src="build/vendor.js"></script>
<!-- cordova.js required for cordova apps -->
<script src="cordova.js"></script>
<!-- The main bundle js is generated during the build process -->
<script src="build/main.js"></script>
</body>
由於應用程序成功運行iOS上 - 我不敢改變 安置cordova.js
我推測是 -
1:這將是最好的創建一個Provider
來存儲在平臺內實例化的每個本機插件的引用 - 並在需要時使用引用
2:可能會丟失一些信息,尤其是關於iOS的,關於Ionic-Native Wrapper
任何建議/討論將不勝感激。