1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-18 22:30:38 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Implement download and install apk

This commit is contained in:
sunnylqm
2020-09-27 22:16:27 +08:00
parent 3c5792423e
commit 17ff366f51
10 changed files with 176 additions and 42 deletions

View File

@@ -21,6 +21,7 @@ import {
switchVersion,
switchVersionLater,
markSuccess,
downloadAndInstallApk,
} from 'react-native-update';
import _updateConfig from '../update.json';
@@ -94,11 +95,29 @@ export default class App extends Component {
return;
}
if (info.expired) {
Alert.alert('提示', '您的应用版本已更新,请前往应用商店下载新的版本', [
Alert.alert('提示', '您的应用版本已更新,点击确定下载安装新版本', [
{
text: '确定',
onPress: () => {
info.downloadUrl && Linking.openURL(info.downloadUrl);
if (info.downloadUrl) {
// apk可直接下载安装
if (
Platform.OS === 'android' &&
info.downloadUrl.endsWith('.apk')
) {
downloadAndInstallApk({
url: info.downloadUrl,
onDownloadProgress: ({received, total}) => {
this.setState({
received,
total,
});
},
});
} else {
Linking.openURL(info.downloadUrl);
}
}
},
},
]);