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

View File

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