From 6dabe3427d73e99d3024996f51d38cbe25dfedec Mon Sep 17 00:00:00 2001 From: Thib Date: Sun, 15 Jan 2017 10:29:51 +0100 Subject: [PATCH] Fix ios other apps audio interruption (#209) * Fix ios other apps audio interruption Other apps audio was interrupted when the background mode was enabled. I found the solution on this post http://stackoverflow.com/questions/10180500/how-to-use-kaudiosessionproperty-overridecategorymixwithothers If we don't disable the audio session before that the option AVAudioSessionCategoryOptionMixWithOthers is set, it interrupts the other apps audio. Because the category 'AVAudioSessionCategoryPlayback' is set and by default the session is already active and this category interrupts other apps audio without the option 'mix with others'. * Update APPBackgroundMode.m --- src/ios/APPBackgroundMode.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ios/APPBackgroundMode.m b/src/ios/APPBackgroundMode.m index 69546ed..d629a19 100644 --- a/src/ios/APPBackgroundMode.m +++ b/src/ios/APPBackgroundMode.m @@ -149,13 +149,14 @@ NSString *const kAPPBackgroundEventFailure = @"failure"; - (void) configureAudioSession { AVAudioSession* session = [AVAudioSession sharedInstance]; - + // Don't activate the audio session yet + [session setActive:NO error:NULL]; // Play music even in background and dont stop playing music // even another app starts playing sound [session setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:NULL]; - + // Active the audio session [session setActive:YES error:NULL]; };