I am making an app in Swift that takes a UIWebView and allows the audio to be playing in the background. The problem is, when I click the home button, the audio pauses but you can resume it from control center or the lock screen. How do I make it so it plays through being closed? I have this code in my ApplicationDelegate DidFinishLaunchingWithOptions:
var activeError: NSError? = nil
AVAudioSession.sharedInstance().setActive(true, error: &activeError)
if let actError = activeError {
println("Error setting audio active: \(actError.code)")
}
var categoryError: NSError? = nil
AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: &categoryError)
if let catError = categoryError {
println("Error setting audio category: \(catError.code
}