Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Commit 6ee2a86

Browse files
Daniel Salinastanguyantoine
Daniel Salinas
authored andcommitted
fix: remove extra pause event related to app suspension in IOS10+
Apparently in IOS10, the OS now sends a 'Suspended' notification AFTER an app has been suspended AND resumed. This led to a bug where pausing and letting the lock screen kick in (which triggers app suspension) results in PLAY followed by a PAUSE event. By checking this new field we are able to suppress the false pause event and provide uninterrupted resumption. See this note for details: https://developer.apple.com/documentation/avfoundation/avaudiosession/1616596-interruptionnotification
1 parent e244e67 commit 6ee2a86

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ios/MusicControlManager.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,9 @@ - (void)audioInterrupted:(NSNotification *)notification {
370370
}
371371
NSInteger interruptionType = [notification.userInfo[AVAudioSessionInterruptionTypeKey] integerValue];
372372
NSInteger interruptionOption = [notification.userInfo[AVAudioSessionInterruptionOptionKey] integerValue];
373-
374-
if (interruptionType == AVAudioSessionInterruptionTypeBegan) {
373+
bool delayedSuspendedNotification = (@available(iOS 10.0, *)) && [notification.userInfo[AVAudioSessionInterruptionWasSuspendedKey] boolValue];
374+
375+
if (interruptionType == AVAudioSessionInterruptionTypeBegan && !delayedSuspendedNotification) {
375376
// Playback interrupted by an incoming phone call.
376377
[self sendEvent:@"pause"];
377378
}

0 commit comments

Comments
 (0)