无法在 Android OS 10 中使用 Cordova 下载文件,而在 android 7 和 9 中使用相同的代码

问题描述

这是用于下载pdf文件并在webview应用程序中打开的cordova文件代码,下面的代码在android 10下工作,而在android 10中,代码fileTransfer.download(uri,fileURL,function (entry) {在故障块中移动。 我该如何解决这个问题?这些版本是在cordova-plugin.js中添加

    "cordova-plugin-file": "4.3.2","cordova-plugin-file-transfer": "1.6.2","cordova-plugin-file-opener2": "2.0.19",downloadFile: function (options,nonce) {
        const headers = {
            "x-nonce": nonce,Authorization: authorizationToken,"User-Agent": "OIC-Authentication"
          },fileTransfer = new window.FileTransfer(),uri = encodeURI(options.url);
        let fileURL = null;

        if (behavIoUr === "ANDROID") {
          fileURL = window.cordova.file.externalRootDirectory + "download/";
        } else if (behavIoUr === "IOS") {
          fileURL = window.cordova.file.documentsDirectory;
        }

        fileTransfer.download(uri,function (entry) {
          window.cordova.plugins.fileopener2.open(entry.nativeURL,entry.mimeType,{
            error: function () {
              $(".se-pre-con").fadeOut();
            },success: function () {
              $(".se-pre-con").fadeOut();
            }
          });
        },null,false,{
          headers: headers
        });
      },

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)