Skip to content

Commit

Permalink
chore: add update manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dpyzo0o committed Dec 17, 2019
1 parent 6cf613e commit 768a19e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,30 @@ class App extends Component {
},
};

componentDidMount() {}
componentDidMount() {
const updateManager = Taro.getUpdateManager();

updateManager.onCheckForUpdate(res => {
console.log(res);
});

updateManager.onUpdateReady(() => {
Taro.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
},
});
});

updateManager.onUpdateFailed(res => {
console.log(res);
});
}

componentDidShow() {}

Expand Down

0 comments on commit 768a19e

Please sign in to comment.