🐛 (notification) try catch notification
This commit is contained in:
@@ -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.')
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user