【问题标题】:Ionic 3 - File Opener not working on iOS via DevAppIonic 3 - 文件打开器无法通过 DevApp 在 iOS 上运行
【发布时间】:2025-12-04 07:05:02
【问题描述】:

任何人都可以帮助弄清楚为什么我的应用坚持 FileOpener 插件实际上没有安装吗?

每次我尝试打开 PDF/Image/Docx/XlSX 或任何其他文件类型时,我都会在控制台中收到如下通知:

我逐行跟踪tutorial here,当我调查文件结构时,我可以看到 FileOpener 插件在那里,请参阅:

在我的 app.module.ts 中:

在我的 user.provider.ts 文件中:

这是我的 DownloadDocument 函数:

async DownloadDocument( location: string, name: string, mime: string, message: string = undefined )
  {
    var loading = await this.ShowLoading( message );

    try
    {
      var dir = '';

      if ( this.IsIOS )
      {
        dir = this.file.documentsDirectory;
      }
      else if ( this.IsAndroid )
      {
        dir = this.file.dataDirectory;
      }

      dir = `${dir}${name.replace(/ /g, '')}`;

      const fileTransfer: FileTransferObject = this.transfer.create();

      fileTransfer.download(`${this.APIUrl}/${location}`, dir, true)
                  .then( ( f ) => 
                  {
                    this.fp.open( f.toURL(), mime ).then( () =>
                    {
                      console.log('File is opened')
                    } )
                    .catch(err =>
                    {
                      console.log('Open Error: ' + JSON.stringify( err ));
                    });

                    loading.dismiss();
                  }, ( error ) => 
                  {
                    console.log('Download Error: ' + JSON.stringify( error ));

                    loading.dismiss();
                  } );

    }
    catch( error )
    {
      console.log('General Error: ' + JSON.stringify( error ));
      loading.dismiss();
    }
  }

需要注意的一点是,如果我使用 DocumentViewer 插件,它可以打开 PDF 文件。但我想使用 FileOpener 插件,因为我打算打开 PDF 以外的其他文件。

谁能看出我做错了什么?

【问题讨论】:

    标签: typescript ionic-framework ionic3 cordova-plugins


    【解决方案1】:

    DevApp 仅具有某些插件,因此并非所有内容都受支持。 在此处查看支持的插件的完整列表: https://ionicframework.com/docs/appflow/devapp#native-cordova-plugin-support

    尝试直接在设备上测试特定插件(ionic cordova run android etc)

    【讨论】: