Improved push notifications for Chrome

This commit is contained in:
Igor Zhukov 2016-12-20 19:32:36 +03:00
parent edbdba582e
commit db5315d7e4
3 changed files with 14 additions and 10 deletions

View File

@ -60,13 +60,15 @@ self.addEventListener('push', function(event) {
})
var closePromise = notificationPromise.catch(function () {
console.log('[SW] Closing all notifications on push')
if (userInvisibleSupported || hasActiveWindows) {
console.log('[SW] Closing all notifications on push', hasActiveWindows)
if (userInvisibleSupported) {
return closeAllNotifications()
}
var promise = self.registration.showNotification('Telegram').then(function () {
// return closeAllNotifications()
setTimeout(closeAllNotifications, 100)
// if (hasActiveWindows) {
// return closeAllNotifications()
// }
setTimeout(closeAllNotifications, hasActiveWindows ? 0 : 100)
}).catch(function (error) {
console.error('Show notification error', error)
})

View File

@ -3627,11 +3627,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
$rootScope.$on('push_notification_click', function (e, notificationData) {
if (notificationData.action == 'push_settings') {
$modal.open({
templateUrl: templateUrl('settings_modal'),
controller: 'SettingsModalController',
windowClass: 'settings_modal_window mobile_modal',
backdrop: 'single'
topMessagesPromise.then(function () {
$modal.open({
templateUrl: templateUrl('settings_modal'),
controller: 'SettingsModalController',
windowClass: 'settings_modal_window mobile_modal',
backdrop: 'single'
})
})
return
}

View File

@ -1,3 +1,3 @@
importScripts('js/lib/push_worker.js')
// Version 50
// Version 53