Apple did not post any alternative code for this on the Apple Developer site.
In swift we can add the following
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setActive(true)
try audioSession.setCategory(AVAudioSessionCategoryPlayback)
} catch {
print("Setting category to AVAudioSessionCategoryPlayback failed.")
}
from: https://developer.apple.com/documentation/avfoundation/avaudiosession