当我尝试使用 inAppBrowser 加载 PDF 文件时,我在 IOS 上遇到了问题。使用相同的代码,我在网上打开文件没有任何问题
我调用 InAppBrowser 来打开这样的 PDF:
this.inAppBrowser.create(helpAsset.url, '_system', 'hideurlbar=yes');
helpAsset.url 定义我的资产/存储库中的文件,它是一个内部文件
当我在调试中使用 xcode 构建我的应用程序并将其放在我的 Ipad(在 IOS 12 上)上时,该文件在 Safari 中打开没有问题。但是使用相同的版本但处于发布模式,文件无法打开并且我有一个空页面
我试图更改“_blank”中的“_system”,但问题是一样的。
我已经读到它可能是一个 CORS 问题,可以用离子原生 http 解决,但我不知道如何将它与 inappBrowser 集成
有人知道怎么修这个东西吗?
最后,
我通过在 Ipad 上创建 PDF 文件来绕过这个问题,从中读取它,它的工作(PDF 不是在 safari 中打开,而是使用默认的 IOS PDF 阅读器插件)
this.file.createDir(rep, 'edossier', true).then(
createDirReturn => {
this.file.createFile(rep + '/edossier', 'pdfToDisplay.pdf', true).then(
createFileReturn => {
this.httpClient.get(helpAsset.url, { responseType: 'blob' }).subscribe(result => {
this.file.writeExistingFile(rep + '/edossier', 'pdfToDisplay.pdf', result).then(
writingFileReturn => {
this.inAppBrowser.create(rep + '/edossier/' + 'pdfToDisplay.pdf', '_blank', 'hideurlbar=no,location=no,toolbarposition=top'
);
}
);
});
});
});
我认为代码可以更好,但这工作正常。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句