File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,40 @@ fn main() {
57
57
}
58
58
```
59
59
60
+ Then you need to add the permissions to your capabilities file:
61
+
62
+ ` src-tauri/capabilities/main.json `
63
+
64
+ ``` json
65
+ {
66
+ ...
67
+ "permissions" : [
68
+ ...
69
+ " notification:default"
70
+ ],
71
+ ...
72
+ }
73
+ ```
74
+
75
+
60
76
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
61
77
62
78
``` javascript
79
+ import { isPermissionGranted , requestPermission , sendNotification } from ' @tauri-apps/plugin-notification' ;
63
80
81
+ async function checkPermission () {
82
+ if (! (await isPermissionGranted ())) {
83
+ return (await requestPermission ()) === ' granted' ;
84
+ }
85
+ return true ;
86
+ }
87
+
88
+ export async function enqueueNotification (title , body ) {
89
+ if (! (await checkPermission ())) {
90
+ return ;
91
+ }
92
+ sendNotification ({ title, body });
93
+ }
64
94
```
65
95
66
96
## Contributing
You can’t perform that action at this time.
0 commit comments