I'm trying to build an alarm app. To play alarms when the app is in the background, my app plays a completely silence sound (however I'm hearing a quiet noise, although if I play the same sound file on my computer there is definitely nothing to hear) in the background until the alarm time comes and the AVPlayer plays the alarm sound. It works, but when my app plays the silent sound in the background, some other apps (especially some games) don't play their sound. This is kind of weird, because there is the app 'Alarmy' in the AppStore, which definitely uses the same system with a silent sound, but when I set an alarm in this app, it doesn't silence any other sound.
How can I achieve this? Currently I'm setting my AVAudioSession like this (I'm setting it in the initializer of my alarm player class, of which i have an instance in my AppDelegate):
let session = AVAudioSession.sharedInstance()
do {
try session.setCategory(AVAudioSessionCategoryPlayback, with: .mixWithOthers)
try session.setActive(true)
} catch {
print("Failed to set audio session category. Error: \(error)")
}
EDIT: For more explanation about the app Alarmy, look also at App "Alarmy" is able to play iTunes song from background state... How?