Custom sound for UNMutableNotificationContent | MacOS

Hello,

I'm developing a macOS bar app and the goal is to fire a notification.

For the notification, I want a specific sound to be played.

However, while I see the notification with the wanted title and body, the sound is always the default notification sound , even though I set it to a custom one !

I looked in the Apple Documentation and verified that everything is correct with the sound file. I tried different files (.wav and .caf) and nothing worked.

In the code block below, the print("Sound URL: (soundURL)") is seen in the console, which means that the file is indeed in the bundle.

Xcode version : 14.3.1 macOS used : Ventura 13.4 Any help would be appreciated :


code-block
 if let soundURL = Bundle.main.url(forResource: "mixkit", withExtension: "wav") {
            print("Sound URL: \(soundURL)")
            content.sound = .init(named: UNNotificationSoundName(soundURL.lastPathComponent))

        } else {
            print("Sound URL not found for mixkit.wav")
        }
        
        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
        
        let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
Custom sound for UNMutableNotificationContent | MacOS
 
 
Q