Trying to handle audio interruption in my project.
This code used to work in swift 4.
NotificationCenter.default.addObserver(self, selector: #selector(handleInterruption(_:)), name: NSNotification.Name.AVAudioSessionInterruption, object: nil)
Since updating to Swift 4.2 it gave me suggestion to change to
NotificationCenter.default.addObserver(self, selector: #selector(handleInterruption(_:)), name: Notification.Name.AVAudioSession.interruptionNotification, object: nil)
After changing to the suggested fix, I am getting Error: Type 'Notification.Name' (aka 'NSNotification.Name') has no member 'AVAudioSession'
Any help would be appreciated.
The Documents used:
func setupNotifications() {
let notificationCenter = NotificationCenter.default
notificationCenter.addObserver(self, selector: #selector(handleInterruption), name: .AVAudioSessionInterruption, object: nil)
}
But the document isn't updated for swift 4.2.