<template></template> <script> import firebase from '../plugins/firebase'; export defautl { created() { const messaging = firebase.messaging(); messaging .requestPermission() .then(() => { console.log('Notification permission granted.'); return messaging.getToken(); }) .then((token) => { // You update this token for server by call api console.log('The token is: ', token); }) .catch(function (err) { console.log('Unable to get permission to notify.', err); }); } } </script>