Last active
August 11, 2020 07:51
-
-
Save daubattu/800e9075d904b951cbd9cc2bc952bae9 to your computer and use it in GitHub Desktop.
How to push notification in NuxtJS with Firebase Cloud Messaging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment