【问题标题】:ionic3 - inappBrowser - IOS files don't loadionic3 - inappBrowser - IOS 文件不加载
【发布时间】:2023-04-01 23:07:01
【问题描述】:

当我尝试使用 inAppBrowser 加载 PDF 文件时,我在 IOS 上遇到问题。 使用相同的代码,我在网络上打开文件没有任何问题

我调用 InAppBrowser 来打开这样的 PDF:

 this.inAppBrowser.create(helpAsset.url, '_system', 'hideurlbar=yes');

helpAsset.url 定义我的资产/存储库中的一个文件,它是一个内部文件

当我在调试中使用 xcode 构建我的应用程序并将其放在我的 Ipad 上(在 IOS 12 上)时,文件在 Safari 中打开没有问题。 但是使用相同的版本但在发布模式下,文件打不开,我有一个空页面

我尝试在“_blank”中更改“_system”,但问题是一样的。

我已经读到它可能是一个 CORS 问题,可以使用 ionic-native http 解决,但我不知道如何将它与 inappBrowser 集成

有人知道如何解决这个问题吗?

【问题讨论】:

标签: ionic3 inappbrowser ios12


【解决方案1】:

最后,

我通过在 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'
                                );
                            }
                        );
                    });
                });
        });

我认为代码可以更好,但这工作正常。

【讨论】:

    猜你喜欢
    • 2018-03-17
    • 2019-11-05
    • 1970-01-01
    • 2018-10-16
    • 1970-01-01
    • 2020-02-05
    • 1970-01-01
    • 1970-01-01
    • 2018-01-10
    相关资源
    最近更新 更多