(message, body)
| 421 | } |
| 422 | |
| 423 | _notify(message, body) { |
| 424 | const config = { |
| 425 | body: body, |
| 426 | icon: '/images/logo_transparent_128x128.png', |
| 427 | } |
| 428 | let notification; |
| 429 | try { |
| 430 | notification = new Notification(message, config); |
| 431 | } catch (e) { |
| 432 | // Android doesn't support "new Notification" if service worker is installed |
| 433 | if (!serviceWorker || !serviceWorker.showNotification) return; |
| 434 | notification = serviceWorker.showNotification(message, config); |
| 435 | } |
| 436 | |
| 437 | // Notification is persistent on Android. We have to close it manually |
| 438 | const visibilitychangeHandler = () => { |
| 439 | if (document.visibilityState === 'visible') { |
| 440 | notification.close(); |
| 441 | Events.off('visibilitychange', visibilitychangeHandler); |
| 442 | } |
| 443 | }; |
| 444 | Events.on('visibilitychange', visibilitychangeHandler); |
| 445 | |
| 446 | return notification; |
| 447 | } |
| 448 | |
| 449 | _messageNotification(message) { |
| 450 | if (document.visibilityState !== 'visible') { |
no test coverage detected