Using existing system sounds in iOS App [swift|
You can use this Swift 5 code to play system sounds:
// import thisimport AVFoundation// create a sound ID, in this case its the tweet sound.let systemSoundID: SystemSoundID = 1016// to play soundAudioServicesPlaySystemSound(systemSoundID)
The most up to date list of sounds I could find are here.
And this is what they all sound like:https://www.youtube.com/watch?v=TjmkmIsUEbA
Swift 4
import AVFoundationAudioServicesPlayAlertSound(SystemSoundID(1322))
Here's a quick way to test the sounds.
import AVFoundationfunc displaySoundsAlert() { let alert = UIAlertController(title: "Play Sound", message: nil, preferredStyle: UIAlertController.Style.alert) for i in 1000...1010 { alert.addAction(UIAlertAction(title: "\(i)", style: .default, handler: {_ in AudioServicesPlayAlertSound(UInt32(i)) self.displaySoundsAlert() })) } alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)) self.present(alert, animated: true, completion: nil)}