From 4293031f1fa358c1219dbdcf7dd01e8b13fac042 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Tue, 28 Apr 2015 10:13:13 +0200 Subject: [PATCH] Catch notification error on Chrome for Android --- src/js/util/notification.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/js/util/notification.js b/src/js/util/notification.js index f719164..bec8669 100644 --- a/src/js/util/notification.js +++ b/src/js/util/notification.js @@ -4,8 +4,9 @@ var ngModule = angular.module('woUtil'); ngModule.service('notification', Notif); module.exports = Notif; -function Notif(appConfig) { +function Notif(appConfig, axe) { this._appConfig = appConfig; + this._axe = axe; if (window.Notification) { this.hasPermission = Notification.permission === "granted"; @@ -39,10 +40,17 @@ Notif.prototype.create = function(options) { }); } - var notification = new Notification(options.title, { - body: options.message, - icon: self._appConfig.config.iconPath - }); + var notification; + try { + notification = new Notification(options.title, { + body: options.message, + icon: self._appConfig.config.iconPath + }); + } catch (err) { + self._axe.error('Displaying notification failed: ' + err.message); + return; + } + notification.onclick = function() { window.focus(); options.onClick();