AppLovin / AppLovin-MAX-SDK-iOS

86 stars 69 forks source link

"Can not load another ad while the ad is showing" when top view controller is dismissed behind the interstitial #343

Open gerchicov-vg opened 3 weeks ago

gerchicov-vg commented 3 weeks ago

MAX SDK Version

12.1.0 - 12.5.0

Device/Platform Info

iOS 15+

Current Behavior

App dismissed the top view when enters background. If an interstitial ad is currently displayed it becomes hidden but remains in memory and app can't show interstitial ads anymore because of "Can not load another ad while the ad is showing"

Expected Behavior

SDK allows to load another ad or you could provide methods to cleanup the closed ad manually.

How to Reproduce

1)present view controller 2)show interstitial 3)enter background 4)dismiss view controller programmatically

Additional Info

No response

gerchicov-vg commented 3 weeks ago

I have also found out that this behaviour depends on added mediation pods. If I use pure applovin sdk then everything works. Pods list:

  pod 'AppLovinMediationAdColonyAdapter'
  pod 'AppLovinMediationFacebookAdapter'
  pod 'AppLovinMediationGoogleAdapter'
  pod 'AppLovinMediationIronSourceAdapter'
  pod 'AppLovinMediationMintegralAdapter'
  pod 'AppLovinMediationTapjoyAdapter'
  pod 'AppLovinMediationUnityAdsAdapter'
  pod 'AppLovinMediationHyprMXAdapter'
  pod 'AppLovinMediationVungleAdapter'
  pod 'AppLovinMediationGoogleAdManagerAdapter'
  pod 'AppLovinMediationByteDanceAdapter'

At least Pangle test ad is not properly closed.

thomasmso commented 3 weeks ago

@gerchicov-vg - Ad view controllers are not meant to be programmatically dismissed by the developers even when the app is backgrounded. This should be left to the discretion of the ad SDK. Doing so will result in unexpected behaviour, as you've observed.

gerchicov-vg commented 3 weeks ago

@thomasmso Why did you immediately close this ticket? It is not resolved. Push/pop and present/dismiss are basic transitions in iOS. Do you mean a developer should write custom transitions when he uses applovin sdk?

And I just call load() and show() for interstitial ad. I don't dismiss this ad view programmatically - I don't even know which view or view controller "owns" this ad.

thomasmso commented 3 weeks ago

@gerchicov-vg - you mentioned "4)dismiss view controller programmatically", so you are saying you aren't dismissing the view controller programmatically now?

gerchicov-vg commented 3 weeks ago

@thomasmso I present my own view controller, then I call interstitial.show(), then I dismiss my own view controller. I do nothing with the interstitial ad directly

thomasmso commented 3 weeks ago

@gerchicov-vg - I see. And you claim that without other ad networks integrated, there were no issues. And you've reproduced it with at least Pangle ads.

ok - let us investigate further on Pangle ads - at the end of the day, their SDK should be able to gracefully handle this condition. But we can reach out to them for this bug as well.

gerchicov-vg commented 3 weeks ago

@thomasmso I use code example from your docs: https://developers.applovin.com/en/ios/ad-formats/interstitial-ads#showing-an-interstitial-ad

/**
 * Show the loaded interstitial ad.
 * <ul>
 * <li>Use @code -[MAInterstitialAd delegate] @endcode to assign a delegate that should be notified about display events.</li>
 * <li>Use @code -[MAInterstitialAd ready] @endcode to check if an ad was successfully loaded.</li>
 * </ul>
 *
 * @see <a href="https://developers.applovin.com/en/ios/ad-formats/interstitial-ads#showing-an-interstitial-ad">MAX Integration Guide ⇒ iOS ⇒ Ad Formats ⇒ Interstitials ⇒ Showing an Interstitial Ad</a>
 */
- (void)showAd;

In Obj-C they called loadAd and showAd but in Swift they are load and show.

So do you suggest to avoid dismissing any of my own view controllers when the interstitial ad presented? It looks strange but at least show method could return a view controller it uses. So I could prevent or delay dismissing for this view controller if it shows any kind of ads.

thomasmso commented 3 weeks ago

@gerchicov-vg - we don't have access to the mediated network's view controller so we can't return that to you when showing. The solution here would be to not update the navigation stack when an ad is showing - operationally it will be nearly impossible to have all ad networks MAX supports support this case. You'll know when an ad is showing and hidden via our - (void)didDisplayAd:(MAAd *)ad and - (void)didHideAd:(MAAd *)ad callbacks.