diff --git a/src/state/epics/timerEpics.ts b/src/state/epics/timerEpics.ts index 1385bc0..9acff94 100644 --- a/src/state/epics/timerEpics.ts +++ b/src/state/epics/timerEpics.ts @@ -14,6 +14,8 @@ import timer from '../../assets/timer.svg' type EpicType = Epic const { stopTimer, countDownFinished, countDownOneSecond } = timerActions +const SOUND_EFFECT = new Audio('https://s3-us-west-2.amazonaws.com/s.cdpn.io/123941/Yodel_Sound_Effect.mp3') + export const startTimerEpic: EpicType = action$ => action$.pipe( filter(isOfType(START_TIMER)), @@ -49,6 +51,7 @@ export const alertEpic: EpicType = (action$, state$) => badge: timer, icon: timer, vibrate: [2000, 2000, 2000], + sound: SOUND_EFFECT, }), ] }), diff --git a/src/utils/notifications.ts b/src/utils/notifications.ts index 56ce554..4e397ee 100644 --- a/src/utils/notifications.ts +++ b/src/utils/notifications.ts @@ -9,6 +9,7 @@ interface INotificationOptions { lang?: string tag?: string vibrate?: number[] + sound?: HTMLAudioElement onClose?: (e: Event) => any } @@ -21,6 +22,9 @@ export function requestPermission() { export function notify(title: string, options?: INotificationOptions) { const notification = new Notification(title, options) + // tslint:disable-next-line: no-floating-promises + if (options && options.sound) options.sound.play() + notification.onclick = () => { notification.close() }