vue-native-notification
Vue.js plugin for native notifications
Install
npm install --save vue-native-notification
Usage
Add plugin
import Vue from 'vue'
import VueNativeNotification from 'vue-native-notification'
Vue.use(VueNativeNotification, {
requestOnNotify: true
})
Show notification
<template>
<button type="button" @click="notify">Show notification</button>
</template>
<script>
export default {
methods: {
notify () {
this.$notification.show('Hello World', {
body: 'This is an example!'
})
}
}
}
</script>
<style>
</style>
Manual permission request
You can manually request users permission with:
Vue.notification.requestPermission()
.then(console.log)
this.$notification.requestPermission()
.then(console.log)
License
MIT