}
if (typeof pollData.notification === "object" && typeof pollData.notification.message === "string") {
- const notification = new window.Notification(pollData.notification.title, {
- body: StringUtil.unescapeHTML(pollData.notification.message).replace(/ /g, "\u202F"),
- icon: this.icon,
- });
+ let notification: Notification;
+
+ try {
+ notification = new window.Notification(pollData.notification.title, {
+ body: StringUtil.unescapeHTML(pollData.notification.message).replace(/ /g, "\u202F"),
+ icon: this.icon,
+ });
+ } catch (e) {
+ // The `Notification` constructor is not available on Android.
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=481856
+ if (e.name === "TypeError") {
+ return;
+ }
+
+ throw e;
+ }
+
notification.onclick = () => {
window.focus();
notification.close();
return;
}
if (typeof pollData.notification === "object" && typeof pollData.notification.message === "string") {
- const notification = new window.Notification(pollData.notification.title, {
- body: StringUtil.unescapeHTML(pollData.notification.message).replace(/ /g, "\u202F"),
- icon: this.icon,
- });
+ let notification;
+ try {
+ notification = new window.Notification(pollData.notification.title, {
+ body: StringUtil.unescapeHTML(pollData.notification.message).replace(/ /g, "\u202F"),
+ icon: this.icon,
+ });
+ }
+ catch (e) {
+ // The `Notification` constructor is not available on Android.
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=481856
+ if (e.name === "TypeError") {
+ return;
+ }
+ throw e;
+ }
notification.onclick = () => {
window.focus();
notification.close();