Update endpoint and example
This commit is contained in:
parent
4cbeb7bec4
commit
f461c8ddd2
@ -52,6 +52,7 @@ export default class App extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
doUpdate = async info => {
|
doUpdate = async info => {
|
||||||
|
try {
|
||||||
const hash = await downloadUpdate(info);
|
const hash = await downloadUpdate(info);
|
||||||
Alert.alert('提示', '下载完毕,是否重启应用?', [
|
Alert.alert('提示', '下载完毕,是否重启应用?', [
|
||||||
{
|
{
|
||||||
@ -68,20 +69,17 @@ export default class App extends Component {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
} catch (err) {
|
||||||
|
Alert.alert('更新失败', err.message);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
checkUpdate = async () => {
|
checkUpdate = async () => {
|
||||||
return await this.doUpdate({
|
|
||||||
update: true,
|
|
||||||
pdiffUrl: 'http://localhost:8888/1.pdiff',
|
|
||||||
hash: 'test',
|
|
||||||
});
|
|
||||||
|
|
||||||
let info;
|
let info;
|
||||||
try {
|
try {
|
||||||
info = await checkUpdate(appKey);
|
info = await checkUpdate(appKey);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(err);
|
Alert.alert('更新检查失败', err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (info.expired) {
|
if (info.expired) {
|
||||||
@ -115,7 +113,7 @@ export default class App extends Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.welcome}>443欢迎使用热更新服务</Text>
|
<Text style={styles.welcome}>欢迎使用热更新服务</Text>
|
||||||
<Image
|
<Image
|
||||||
resizeMode={'contain'}
|
resizeMode={'contain'}
|
||||||
source={require('./assets/shezhi.png')}
|
source={require('./assets/shezhi.png')}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
let currentEndpoint = 'https://update.reactnative.cn/api';
|
let currentEndpoint = 'https://update.react-native.cn/api';
|
||||||
|
|
||||||
function ping(url, rejectImmediate) {
|
function ping(url, rejectImmediate) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user