AVSpeechUtterance utterance voice in silent mode
Add the below code before your code. You can write the same code in appDelegate also.
NSError *setCategoryErr = nil;
NSError *activationErr = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:&setCategoryErr];
[[AVAudioSession sharedInstance] setActive:YES error:&activationErr];
Swift 3.0 answer
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
}
catch let error as NSError {
print("Error: Could not set audio category: \(error), \(error.userInfo)")
}
do {
try AVAudioSession.sharedInstance().setActive(true)
}
catch let error as NSError {
print("Error: Could not setActive to true: \(error), \(error.userInfo)")
}