Plays a system sound as an alert.


func AudioServicesPlayAlertSound(_ inSystemSoundID: SystemSoundID)



The system sound object to play as an alert.

Before using this function, call the AudioServicesCreateSystemSoundID(_:_:) function to obtain a system sound.


Depending on the particular iOS device, this function plays a short sound and may invoke vibration. Calling this function does the following on various iOS devices:

  • iPhone—plays the specified sound. If the user has configured the Settings application for vibration on ring, also invokes vibration. However, the device does not vibrate if your app’s audio session is configured with the playAndRecord or record audio session category. This ensures that vibration doesn’t interfere with audio recording. For an explanation of audio session categories, see Categories Express Audio Roles.

  • iPod touch, original—plays a short alert melody.

  • iPod touch, 2nd generation and newer—plays the specified sound.

In iOS, the duration of the sound to be played must not be more than 30 seconds.

In macOS, when a user has configured System Preferences to flash the screen for alerts, or if sound cannot be rendered, calling this function will result in the screen flashing. In macOS, pass the constant kSystemSoundID_UserPreferredAlert to play the alert sound selected by the user in System Preferences. In iOS there is no preferred user alert sound.

To play a short sound not used as an alert, use AudioServicesPlaySystemSound(_:).

See Also

Playing Sounds