2
0
mirror of https://github.com/tenrok/vue-native-notification.git synced 2026-05-17 05:59:39 +03:00
Amandio Magalhaes d9dd6b2e45 Added events
2018-01-03 12:13:37 -02:00
2017-08-26 21:28:21 +02:00
2017-08-26 21:28:21 +02:00
2018-01-03 12:13:37 -02:00
2017-08-26 21:28:35 +02:00
2018-01-03 12:13:37 -02:00
2017-08-26 22:18:12 +02:00
2018-01-03 12:13:37 -02:00
2017-08-26 21:28:21 +02:00

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 permission 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

MIT

S
Description
No description provided
Readme 174 KiB
Languages
JavaScript 100%