🐛 (notification) try catch notification

This commit is contained in:
2020-07-02 08:46:19 +02:00
parent 53f8609885
commit f0a9fdd38a
2 changed files with 19 additions and 14 deletions

View File

@@ -4,11 +4,12 @@ import { register } from 'register-service-worker'
if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, {
ready() {
ready(sw) {
console.log(
'App is being served from cache by a service worker.\n' +
'For more details, visit https://goo.gl/AFskqB'
)
sw.showNotification('Coucou')
},
registered() {
console.log('Service worker has been registered.')

View File

@@ -1,6 +1,7 @@
declare const Notification: any
export const notify = (message: string) => {
try {
if (!('Notification' in window)) {
return
} else if (Notification.permission === 'granted') {
@@ -16,4 +17,7 @@ export const notify = (message: string) => {
}
})
}
} catch (error) {
return
}
}