【发布时间】:2020-06-16 08:35:22
【问题描述】:
我在app.component.ts中添加了以下代码
constructor(private updates: SwUpdate,){
{
console.warn('check');
this.updates.available.subscribe(event => {
console.log('current version is', event.current);
console.log('available version is', event.available);
updates.activateUpdate().then(() => {
console.warn('downloaded');
document.location.reload();
});
});
this.updates.activated.subscribe(event => {
console.log('old version was', event.previous);
console.log('new version is', event.current);
});
}
我想在上传新版本时通知用户,点击它时会加载新版本。
我是否需要编写服务,将版本号存储在服务器和本地存储中并不断检查新版本?
我还需要在app.component.ts 中做其他事情吗?
event.current、event.available 值从何而来?
编辑 1
即使我上传新版本,我也不会在控制台中看到这些消息
console.log('current version is', event.current);
console.log('available version is', event.available);
这是什么原因?
【问题讨论】:
标签: angular ionic-framework ionic4 progressive-web-apps