4

I have an app produced in Xcode prior to iOS 13. The app does not support multiple windows. While we have experienced weirdness with AppDelegate before, there seems to be more weirdness since iOS 13 was released, and I was hoping to see if others have experienced something similar.

Specifically, if I enter multitask mode (double tap on home button on older iPhones or swipe up from bottom of the screen and pause s.t. all background app windows are displayed) and then reenter my app, AppDelegate seems to trigger appropriately when debugging, but if left to its own devices music in my app--which is typically brought back in applicationDidBecomeActive--is not restored.

UPDATED: this specifically seems to be related to music / sound--iOS appears to be taking any players and setting them to nil, not allowing me to stop them. iOS also appears to ignore instructions in AppDelegate to load and play music. What is the story here?

I understand from this post: App delegate methods aren't being called in iOS 13 that it is important to either not support multiple windows OR manage instructions traditionally called in App Delegate in the new Scene Delegate; however, is it more critical than it appears that I call Scene Delegate? Is there another explanation for this behavior in iOS 13 or another workaround that I can use?

Summary code in AppDelegate:

func applicationDidBecomeActive(_ application: UIApplication)
{
...
// Check to see if there is secondary audio playing; if true, stop our audio and eliminate all queued up music
        if AVAudioSession.sharedInstance().secondaryAudioShouldBeSilencedHint
        {
            AssetsSounds.sharedInstance.bgmGamePlayer?.stop()
            AssetsSounds.sharedInstance.bgmGamePlayer = nil
            needToPlayGameMusic = false
            AssetsSounds.sharedInstance.bgmTitlePlayer?.stop()
            AssetsSounds.sharedInstance.bgmTitlePlayer = nil
            needToPlayTitleMusic = false
            ...
        }
        // if no secondary music, check to see if we need to restart any of the bgm players
        else if needToPlayGameMusic || needToPlayTitleMusic || needToPlayBonusLoop || needToPlayBonusLeadIn || needToPlayFiveMovesLeft
        {
            // play background music if it needs to be played
            if needToPlayTitleMusic
            {
                AssetsSounds.sharedInstance.bgmTitlePlayer?.play()
                needToPlayTitleMusic = false
            }

            // play game music if it needs to be played
            else if needToPlayGameMusic
            {
                AssetsSounds.sharedInstance.bgmGamePlayer?.play()
                needToPlayGameMusic = false
            }
            ...


    } // end else if
...
}
Mike Pandolfini
  • 532
  • 4
  • 17
  • have you checked with breakpoints inside `applicationDidBecomeActive` – Pranavan SP Nov 14 '19 at 10:33
  • there is no all code provided but do you activate AVAudioSession somewhere on return from background? – Asperi Nov 16 '19 at 06:10
  • Yes—if I breakpoint everything works fine. And no, I don’t reactivate the session, but sound FX return and music plays once it’s triggered in the app, so that doesn’t seem to be the issue. – Mike Pandolfini Nov 16 '19 at 21:35

0 Answers0