Posted when an audio interruption occurs.
SDKs
- iOS 6.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- AVFoundation
Declaration
class let interruptionNotification: NSNotification.Name
Discussion
The user
dictionary of this notification contains the AVAudio
. If the interruption type is AVAudio
, the app’s audio session has been interrupted and is no longer active. If the interruption type is AVAudio
, this dictionary also contains the AVAudio
key.
See Responding to Interruptions in Media Playback Programming Guide for more information on using this notification.
This notification is posted on the main thread.
Note
Starting in iOS 10, the system will deactivate the audio session of most apps in response to the app process being suspended. When the app starts running again, it will receive an interruption notification that its audio session has been deactivated by the system. This notification is necessarily delayed in time because it can only be delivered once the app is running again. If your app's audio session was suspended for this reason, the user
dictionary will contain the AVAudio
key with a value of true
.
If your audio session is configured to be non-mixable (the default behavior for the playback
, play
, solo
, and multi
categories), it's recommended that you deactivate your audio session if you're not actively using audio when you go into the background. Doing so will avoid having your audio session deactivated by the system (and receiving this somewhat confusing notification).