mirror of
https://github.com/tenrok/vue-native-notification.git
synced 2026-05-17 04:59:37 +03:00
ee04cafad5dbc981142689a77a68b669d4788ea6
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, {
// Automatic permiossion request before
// showing notification (default: true)
requestOnNotify: true
})
Show notification
<template>
<button type="button" @click="notify">Show notification</button>
</template>
<script>
export default {
methods: {
notify () {
// https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification#Parameters
this.$notification.show('Hello World', {
body: 'This is an example!'
})
}
}
}
</script>
<style>
</style>
Manual permission request
You can manually request users permission with:
// Global
Vue.notification.requestPermission()
.then(console.log) // Prints "granted", "denied" or "default"
// Component
this.$notification.requestPermission()
.then(console.log)
License
Description
Languages
JavaScript
100%