Browse Source

Added IE10+ notifications support

master
Igor Zhukov 10 years ago
parent
commit
65eb3a6ab6
  1. 24
      app/js/services.js

24
app/js/services.js

@ -1818,6 +1818,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
function notifyAboutMessage (message) { function notifyAboutMessage (message) {
console.warn('notify about message');
var peerID = getMessagePeer(message); var peerID = getMessagePeer(message);
var fromUser = AppUsersManager.getUser(message.from_id); var fromUser = AppUsersManager.getUser(message.from_id);
var fromPhoto = AppUsersManager.getUserPhoto(message.from_id, 'User'); var fromPhoto = AppUsersManager.getUserPhoto(message.from_id, 'User');
@ -3352,7 +3353,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
navigator.vibrate = navigator.vibrate || navigator.mozVibrate || navigator.webkitVibrate; navigator.vibrate = navigator.vibrate || navigator.mozVibrate || navigator.webkitVibrate;
var notificationsUiSupport = ('Notification' in window) || ('mozNotification' in navigator); var notificationsUiSupport = ('Notification' in window) ||
('mozNotification' in navigator) ||
window.external && window.external.msIsSiteMode();
var notificationsShown = {}; var notificationsShown = {};
var notificationIndex = 0; var notificationIndex = 0;
var notificationsCount = 0; var notificationsCount = 0;
@ -3495,7 +3498,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
function notify (data) { function notify (data) {
// console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport); console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport);
// FFOS Notification blob src bug workaround // FFOS Notification blob src bug workaround
if (Config.Navigator.ffos) { if (Config.Navigator.ffos) {
@ -3541,6 +3544,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
else if ('mozNotification' in navigator) { else if ('mozNotification' in navigator) {
notification = navigator.mozNotification.createNotification(data.title, data.message || '', data.image || ''); notification = navigator.mozNotification.createNotification(data.title, data.message || '', data.image || '');
} }
else if (window.external && window.external.msIsSiteMode()) {
window.external.msSiteModeClearIconOverlay();
console.log('notify', data.image, data.title);
window.external.msSiteModeSetIconOverlay('img/icons/icon16.png', data.title + (data.message ? ' ' + data.message : ''));
window.external.msSiteModeActivate();
notification = {
index: idx
};
}
else { else {
return; return;
} }
@ -3585,12 +3597,19 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (notification.close) { if (notification.close) {
notification.close(); notification.close();
} }
else if (notification.index == notificationIndex &&
window.external && window.external.msIsSiteMode()) {
window.external.msSiteModeClearIconOverlay();
}
} catch (e) {} } catch (e) {}
delete notificationsCount[key]; delete notificationsCount[key];
} }
} }
function notificationsClear() { function notificationsClear() {
if (window.external && window.external.msIsSiteMode()) {
window.external.msSiteModeClearIconOverlay();
} else {
angular.forEach(notificationsShown, function (notification) { angular.forEach(notificationsShown, function (notification) {
try { try {
if (notification.close) { if (notification.close) {
@ -3598,6 +3617,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
} catch (e) {} } catch (e) {}
}); });
}
notificationsShown = {}; notificationsShown = {};
notificationsCount = 0; notificationsCount = 0;
} }

Loading…
Cancel
Save