Is AdMob Banner Ad in my iOS app interrupting background audio from other apps?

435 Views Asked by At

I noticed a problem with my iOS app where audio playing from other apps (e.g. Podcast app) sometimes stops while my app is active. My app does not play any audio (it is quiet) and I would like background audio from other apps to continue to play while my app is in use. I tried setting AVAudioSession Category with option .mixWithOthers as suggested in this post:

In Swift, how do I let other apps continue to play audio when my app is open?

However, audio still stops when some Google banner Ads get loaded. Specifically, the culprits seem to be some banner ads that seem to have some animation (e.g. coinbase ads). Is it possible that the Google Ad code or the specific Ad itself is causing the audio interrupt? If so, how do I keep it from doing this and allow background apps to keep playing audio while my app is running and loading new Ads?

To reiterate (since I was asked to re-write this post), the desired behavior is that any audio that is playing by another app when my app is launched and running, should continue to play and not be interrupted by my app or the admob banner Ad within my app. The specific problem is that audio (like podcasts) sometimes stops playing while my app is in the foreground (not always) and I suspect it has something to do with Google Banner ads. I could not reproduce the audio interrupts when I removed the Ad from my code but I would like to keep that in. To reproduce, use the code below in your app, play a podcast, launch the app and wait for an ad with animation to load in the banner ad (e.g. coinbase ad):

   include GoogleMobileAds

   @IBOutlet weak var bannerAd: GADBannerView!

   let request = GADRequest()
    
   //Setup Ad
    bannerAd.adUnitID = "<your app id here>"
    
    bannerAd.rootViewController = self
    bannerAd.delegate = self
    
    bannerAd.load(request)

I am using Xcode 12.4; Swift 5; GAD SDK version: afma-sdk-i-v7.64.0

0

There are 0 best solutions below