Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit ee04caf

Browse files
committed
Add readme
1 parent a7ab86f commit ee04caf

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# vue-native-notification
2+
3+
Vue.js plugin for native notifications
4+
5+
## Install
6+
7+
```
8+
npm install --save vue-native-notification
9+
```
10+
11+
## Usage
12+
13+
### Add plugin
14+
15+
```javascript
16+
import Vue from 'vue'
17+
import VueNativeNotification from 'vue-native-notification'
18+
19+
Vue.use(VueNativeNotification, {
20+
// Automatic permiossion request before
21+
// showing notification (default: true)
22+
requestOnNotify: true
23+
})
24+
```
25+
26+
### Show notification
27+
28+
```html
29+
<template>
30+
<button type="button" @click="notify">Show notification</button>
31+
</template>
32+
33+
<script>
34+
export default {
35+
methods: {
36+
notify () {
37+
// https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification#Parameters
38+
this.$notification.show('Hello World', {
39+
body: 'This is an example!'
40+
})
41+
}
42+
}
43+
}
44+
</script>
45+
46+
<style>
47+
</style>
48+
```
49+
50+
### Manual permission request
51+
52+
You can manually request users permission with:
53+
54+
```javascript
55+
// Global
56+
Vue.notification.requestPermission()
57+
.then(console.log) // Prints "granted", "denied" or "default"
58+
59+
// Component
60+
this.$notification.requestPermission()
61+
.then(console.log)
62+
```
63+
64+
## License
65+
66+
[MIT](LICENSE.md)

0 commit comments

Comments
 (0)