@@ -39,6 +39,9 @@ impl<R: Runtime> crate::NotificationBuilder<R> {
39
39
if let Some ( icon) = self . data . icon {
40
40
notification = notification. icon ( icon) ;
41
41
}
42
+ if let Some ( sound) = self . data . sound {
43
+ notification = notification. sound ( sound) ;
44
+ }
42
45
#[ cfg( feature = "windows7-compat" ) ]
43
46
{
44
47
notification. notify ( & self . app ) ?;
@@ -102,6 +105,8 @@ mod imp {
102
105
title : Option < String > ,
103
106
/// The notification icon.
104
107
icon : Option < String > ,
108
+ /// The notification sound.
109
+ sound : Option < String > ,
105
110
/// The notification identifier
106
111
identifier : String ,
107
112
}
@@ -136,6 +141,13 @@ mod imp {
136
141
self
137
142
}
138
143
144
+ /// Sets the notification sound file.
145
+ #[ must_use]
146
+ pub fn sound ( mut self , sound : impl Into < String > ) -> Self {
147
+ self . sound = Some ( sound. into ( ) ) ;
148
+ self
149
+ }
150
+
139
151
/// Shows the notification.
140
152
///
141
153
/// # Examples
@@ -177,6 +189,9 @@ mod imp {
177
189
} else {
178
190
notification. auto_icon ( ) ;
179
191
}
192
+ if let Some ( sound) = self . sound {
193
+ notification. sound_name ( & sound) ;
194
+ }
180
195
#[ cfg( windows) ]
181
196
{
182
197
let exe = tauri:: utils:: platform:: current_exe ( ) ?;
@@ -250,6 +265,7 @@ mod imp {
250
265
}
251
266
}
252
267
268
+ /// Shows the notification on Windows 7.
253
269
#[ cfg( all( windows, feature = "windows7-compat" ) ) ]
254
270
fn notify_win7 < R : tauri:: Runtime > ( self , app : & tauri:: AppHandle < R > ) -> crate :: Result < ( ) > {
255
271
let app_ = app. clone ( ) ;
0 commit comments