From 9b2d4987155a66d5b938b0bbab10cf2cd6c68182 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sun, 30 May 2021 20:26:20 +0300 Subject: [PATCH] Notifications: Vibrate only if supported (#1124) --- src/util/notifications.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/util/notifications.ts b/src/util/notifications.ts index cfc3778fe..c25fc1703 100644 --- a/src/util/notifications.ts +++ b/src/util/notifications.ts @@ -277,13 +277,18 @@ export function showNewMessageNotification({ } } else { const dispatch = getDispatch(); - const notification = new Notification(title, { + const options: NotificationOptions = { body, icon: 'icon-192x192.png', badge: 'icon-192x192.png', tag: message.id.toString(), - vibrate: [200, 100, 200], - }); + }; + + if ('vibrate' in navigator) { + options.vibrate = [200, 100, 200]; + } + + const notification = new Notification(title, options); notification.onclick = () => { notification.close();