iOS TTS with phone call interruption

410 Views Asked by At

I have iOS7 application that play some voice commands using Apple TTS engine, I am using this to setup my audio session:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
                          withOptions:AVAudioSessionCategoryOptionDuckOthers
                                error:&error];
[[AVAudioSession sharedInstance] setActive:YES error:&err];

then play my command.

The problem that I have now is that if my phone receives a phone call my application will continue playing its voice command during the phone call, the expectation is that my application will be paused once I answered the phone call and then resume after the call is done.

Is there any thing that I can do to make sure that the phone call will pause my app?

1

There are 1 best solutions below

3
On

When a phone call comes in, the - (void)applicationWillResignActive:(UIApplication *)application method should be called in you app delegate. This is where you should pause the audio.