【发布时间】:2019-05-29 14:52:44
【问题描述】:
我想在我的应用中添加浏览器通知,所以我创建了这个功能:
showNotification() {
navigator.serviceWorker.getRegistration()
.then( function(reg){
reg.showNotification('finish button clicked');
});
}
我从这里打电话:
stop() {
this.showNotification();
}
但我收到此错误:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'showNotification' of undefined
我做错了什么?有没有更好的方法来利用浏览器通知而无需来自后端的任何消息?
【问题讨论】:
标签: angular google-chrome push-notification