Итак, я пытаюсь написать файл (точнее, geoJSON), отлично работает на Android, но на iOS я получаю «код: неверный тип параметра». Содержимое представляет собой строку JSON, поэтому не уверен, что происходит.
Это моя saveFile
функция:
private saveFile(fileName: string, data: string, okMessage: string, errorMessage: string) {
this.file.writeFile(this.dir, fileName, data, { replace: true })
.then(_ => {
this.loadingServiceProvider.dismiss();
this.showMessage(`${okMessage} ${fileName}`);
})
.catch(err => {
this.loadingServiceProvider.dismiss();
this.showMessage(`${errorMessage} ${fileName}`);
console.log(err)
});
}
this.dir
инициализируется в функции init
(вызов конструктора):
init() {
console.log(`file: ${this.file}`)
this.dir = this.file.dataDirectory;
console.log(`file.dataDirectory: ${this.file.dataDirectory}`)
if (this.connectivityServiceProvider.isAndroid()) {
this.dir = this.file.externalDataDirectory;
console.log(`file.externalDataDirectory: ${this.file.externalDataDirectory}`)
} else if (this.connectivityServiceProvider.isIOS()) {
this.dir = this.file.documentsDirectory;
console.log(`file.documentsDirectory: ${this.file.documentsDirectory}`)
}
console.log(`dir: ${this.dir}`)
this.shareServiceProvider.setExportDirectory(this.dir);
}
this.file
является '@ionic-native/file'