From 77767cab9b6bdc251c8c520988d7e426c5c33d3a Mon Sep 17 00:00:00 2001 From: Jesper Charles Balslev Date: Tue, 24 Mar 2020 14:00:17 +0000 Subject: [PATCH] Merged in JesperBalslev/cordova-plugin-run-in-background (pull request #5) Prevent sound/music from stopping when opening the app on iOS. Also prevents embedded videos (youtube) from pausing when unmuted. * Previous fix wasn't backwards compatible with versions older than 12.2. This fixes it. * Fixes iOS issues with backgroundMode.onactivate and backgroundMode.ondeactivate * Prevent sound/music from stopping when opening the app on iOS. Also prevents embedded videos (youtube) from pausing when unmuted. Approved-by: Nathan Kerr --- src/ios/APPBackgroundMode.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ios/APPBackgroundMode.m b/src/ios/APPBackgroundMode.m index 4537fcc..f28d1b2 100644 --- a/src/ios/APPBackgroundMode.m +++ b/src/ios/APPBackgroundMode.m @@ -174,6 +174,9 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; // even another app starts playing sound [session setCategory:AVAudioSessionCategoryPlayback error:NULL]; + // Prevent sound/music from stopping when opening the app. Also prevents embedded videos from pausing when unmuted. + [session setCategory:AVAudioSessionCategoryAmbient + error:NULL]; // Active the audio session [session setActive:YES error:NULL];