本文整理汇总了TypeScript中@angular/service-worker.NgServiceWorker类的典型用法代码示例。如果您正苦于以下问题:TypeScript NgServiceWorker类的具体用法?TypeScript NgServiceWorker怎么用?TypeScript NgServiceWorker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NgServiceWorker类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(serviceWorker: NgServiceWorker) {
serviceWorker.registerForPush()
.subscribe(registration => console.log(JSON.stringify(registration)));
}
示例2: initPushNotification
initPushNotification(){
this.serviceWorker.registerForPush({
applicationServerKey: FAKE_KEY,
}).subscribe((pushRegistration) => {
console.log(pushRegistration);
// Send the key to the server
});
}
示例3: init
init() {
this.sw.log().subscribe(logs => log(logs));
this.sw.updates.subscribe(res => {
if (res.type === 'pending') {
let toast = this.toastCtrl.create({
message: 'A new version is available, reload ',
closeButtonText: "Reload",
showCloseButton: true,
});
toast.onDidDismiss((data, role) => {
if (role === 'close') {
this.sw.activateUpdate(res.version)
.subscribe(value => value && location.reload());
};
});
toast.present();
}
});
this.sw.checkForUpdate();
}
示例4:
toast.onDidDismiss((data, role) => {
if (role === 'close') {
this.sw.activateUpdate(res.version)
.subscribe(value => value && location.reload());
};
});