微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决无法在 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 举报,一经查实,本站将立刻删除。