本文整理匯總了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());
};
});