M
M
Maxim2020-01-16 20:17:27
Vue.js
Maxim, 2020-01-16 20:17:27

Play audio signal on push notification?

How to make, when displaying push notifications on the site, so that there is an audio signal, such as in VK?

const app = new Vue({
    el: '#app',
    data: function() {
        return {

        }
    },
    mounted(){
        window.Echo.private('user_notif')
            .listen('UserNotification', (e) => {
                console.log(e);
            });

    },
    methods: {

    }
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-01-16
@Aslero

I decided

const app = new Vue({
    el: '#app',
    data: function() {
        return {

        }
    },
    mounted(){
        window.Echo.private('user_notif')
            .listen('UserNotification', (e) => {
                var audio = new Audio('/sounds/push.mp3'); // path to file
                audio.play();
                console.log(e);
            });

    },
    methods: {

    }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question