繁体   English   中英

如何打开刚从react-native Webview下载的apk文件?

[英]How can I open apk file I just download from react-native Webview?

我正在尝试使用react-native-webview下载Android apk文件。 它实际上可以下载apk文件!

但是,如何知道文件何时下载成功并获取文件路径或自动安装我刚刚下载的apk文件?

有没有实现它的良好理想? 很感谢

下载到设备路径后,您可以使用两个模块进行尝试。

您必须安装两个模块并且可用。 react-native-file-viewerreact-native-document-picker

import FileViewer from 'react-native-file-viewer';
import { DocumentPicker, DocumentPickerUtil } from 'react-native-document-picker';

DocumentPicker.show({
  filetype: [DocumentPickerUtil.allFiles()],
}, (error, res) => {
  if(res) {
    FileViewer.open(res.uri)
    .then(() => {
      // success
    })
    .catch(_err => {
      // error
    });
  }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM