Notifications: Vibrate only if supported (#1124)

This commit is contained in:
Alexander Zinchuk 2021-05-30 20:26:20 +03:00
parent 6732636dcb
commit 9b2d498715

View File

@ -277,13 +277,18 @@ export function showNewMessageNotification({
} }
} else { } else {
const dispatch = getDispatch(); const dispatch = getDispatch();
const notification = new Notification(title, { const options: NotificationOptions = {
body, body,
icon: 'icon-192x192.png', icon: 'icon-192x192.png',
badge: 'icon-192x192.png', badge: 'icon-192x192.png',
tag: message.id.toString(), 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.onclick = () => {
notification.close(); notification.close();