mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 13:23:12 +08:00 
			
		
		
		
	Implement download and install apk
This commit is contained in:
		| @@ -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); | ||||
|               } | ||||
|             } | ||||
|           }, | ||||
|         }, | ||||
|       ]); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm