I'm developing an app that does some recording both when the app is in the foreground and background. Which is working. However, I've noticed that 'system' sounds like push notification alert sounds as well as vibrations are muted whenever my audio session (see below) is active. This is true even when the app is in the background.
The result is that I stop getting notification sounds/vibe for standard things like text messages, while my app is in the background and recording is on.
Audio session is set as follows:
AVAudioSession* session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&error];
Evidently those sounds/vibrations are non-mixable and so I guess they get muted.
Is there any way around this (while still keeping recording active)? How can I record and still let user get push notification sounds and vibrations?
You could try this:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
withOptions:(AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionDuckOthers)
error:nil];
Also, you could experiment with de-activating audio session using this:
[[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];
And then re-activating it:
[[AVAudioSession sharedInstance] setActive:YES error:nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With