From 1dab2de6ec16e9e6db8c350ee3d1cc9d4bced73a Mon Sep 17 00:00:00 2001 From: Jesper Charles Balslev Date: Thu, 12 Dec 2019 17:28:49 +0000 Subject: [PATCH 1/2] Merged in JesperBalslev/cordova-plugin-run-in-background (pull request #4) Fixes iOS issues with backgroundMode.onactivate and backgroundMode.ondeactivate --- src/ios/APPBackgroundMode.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ios/APPBackgroundMode.m b/src/ios/APPBackgroundMode.m index be941ee..4537fcc 100644 --- a/src/ios/APPBackgroundMode.m +++ b/src/ios/APPBackgroundMode.m @@ -221,8 +221,8 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; NSString* flag = [NSString stringWithFormat:@"%@._isActive=%@;", kAPPBackgroundJsNamespace, active]; - - NSString* depFn = [NSString stringWithFormat:@"%@.on%@();", + + NSString* depFn = [NSString stringWithFormat:@"%@.on('%@');", kAPPBackgroundJsNamespace, event]; NSString* fn = [NSString stringWithFormat:@"%@.fireEvent('%@');", From 77767cab9b6bdc251c8c520988d7e426c5c33d3a Mon Sep 17 00:00:00 2001 From: Jesper Charles Balslev Date: Tue, 24 Mar 2020 14:00:17 +0000 Subject: [PATCH 2/2] 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];