我正在使用 cordova-plugin-file 將 pdf 檔案保存到用戶的
async saveDocument(base64Response: string, fileName: string) {
const folderPath = this.file.documentsDirectory;
await window.resolveLocalFileSystemURL(
folderPath,
(directoryEntry) => {
directoryEntry.getDirectory(
'appFolder',
{ create: true, exclusive: false },
(downloadDirectoryEntry) => {
downloadDirectoryEntry.getFile(fileName, { create: true, exclusive: false }, (fileEntry) => {
fileEntry.createWriter(
async (writer) => {
writer.onerror = (error) => {
console.log('Write failed: ' error.toString());
};
const document = await this.base64ToBlobPdfDocument(base64Response);
await writer.write(document);
},
(error) => {
console.error('writer error', error);
},
);
});
},
(error) => {
console.error('error getting download directory! ', error);
},
);
},
(error) => {
console.error('error getting data directory! ', error);
},
);
}
在 android 中它作業正常,用戶可以訪問它,但在 ios 中我找不到該檔案。
我嘗試了以下設定,但沒有奏效
config.xml 檔案:
<platform name="ios">
<edit-config file="*-Info.plist" mode="merge" target="UIFileSharingEnabled">
<string>Es necesario acceder a los directorios del dispositivo</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="LSSupportsOpeningDocumentsInPlace">
<string>Es necesario abrir documentos desde la aplicación</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="UISupportsDocumentBrowser">
<string>Es necesario acceder al buscador de documentos</string>
</edit-config>
</platform>
uj5u.com熱心網友回復:
最后它使用以下配置
<config-file platform="ios" target="*-Info.plist" parent="UIFileSharingEnabled">
<true/>
</config-file>
<config-file platform="ios" target="*-Info.plist" parent="LSSupportsOpeningDocumentsInPlace">
<true/>
</config-file>
<config-file platform="ios" target="*-Info.plist" parent="UISupportsDocumentBrowser">
<true/>
</config-file>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/409612.html
標籤:
上一篇:在MacM1Monterey上為Rcpp和其他工具安裝編譯器
下一篇:在父型別的方法中回傳子類
