Improved PUSH-handling in Chrome

Possibly fixes #1458
This commit is contained in:
Igor Zhukov 2017-12-29 15:44:32 +04:00
parent ac815f764a
commit 7d408a6dbe

View File

@ -54,13 +54,13 @@ self.addEventListener('push', function(event) {
var closePromise = notificationPromise.catch(function () {
console.log('[SW] Closing all notifications on push', hasActiveWindows)
if (userInvisibleIsSupported()) {
if (userInvisibleIsSupported() || hasActiveWindows) {
return closeAllNotifications()
}
var promise = self.registration.showNotification('Telegram').then(function () {
// if (hasActiveWindows) {
// return closeAllNotifications()
// }
if (hasActiveWindows) {
return closeAllNotifications()
}
setTimeout(closeAllNotifications, hasActiveWindows ? 0 : 100)
}).catch(function (error) {
console.error('Show notification error', error)
@ -133,6 +133,8 @@ function fireNotification(obj, settings, lang) {
tag = 'unknown_peer'
}
console.log('[SW] show notify', title, body, icon, obj)
var notificationPromise = self.registration.showNotification(title, {
body: body,
icon: icon,