@@ -39,6 +39,9 @@ impl<R: Runtime> crate::NotificationBuilder<R> {
3939 if let Some ( icon) = self . data . icon {
4040 notification = notification. icon ( icon) ;
4141 }
42+ if let Some ( sound) = self . data . sound {
43+ notification = notification. sound ( sound) ;
44+ }
4245 #[ cfg( feature = "windows7-compat" ) ]
4346 {
4447 notification. notify ( & self . app ) ?;
@@ -102,6 +105,8 @@ mod imp {
102105 title : Option < String > ,
103106 /// The notification icon.
104107 icon : Option < String > ,
108+ /// The notification sound.
109+ sound : Option < String > ,
105110 /// The notification identifier
106111 identifier : String ,
107112 }
@@ -136,6 +141,13 @@ mod imp {
136141 self
137142 }
138143
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+
139151 /// Shows the notification.
140152 ///
141153 /// # Examples
@@ -177,6 +189,9 @@ mod imp {
177189 } else {
178190 notification. auto_icon ( ) ;
179191 }
192+ if let Some ( sound) = self . sound {
193+ notification. sound_name ( & sound) ;
194+ }
180195 #[ cfg( windows) ]
181196 {
182197 let exe = tauri:: utils:: platform:: current_exe ( ) ?;
@@ -250,6 +265,7 @@ mod imp {
250265 }
251266 }
252267
268+ /// Shows the notification on Windows 7.
253269 #[ cfg( all( windows, feature = "windows7-compat" ) ) ]
254270 fn notify_win7 < R : tauri:: Runtime > ( self , app : & tauri:: AppHandle < R > ) -> crate :: Result < ( ) > {
255271 let app_ = app. clone ( ) ;
0 commit comments