question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS Bug: Ad callbacks not triggering (reproducible)

See original GitHub issue

[REQUIRED] Step 1: Describe your environment

  • Unity version: 2021.2.1, 2021.1.1
  • Google Mobile Ads Unity plugin version: 6.1.2
  • Platform: iOS
  • Platform OS version: iOS 15.2, 15.1
  • Any specific devices issue occurs on: any iOS device
  • Mediation ad networks used, and their versions: none

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

AdMob Event Issue (2021.2.1).zip

  1. build and run the provided project on iOS
  2. open the app and wait for AdMob to initialize and load an ad
  3. press the ‘Show Ad’ button
  4. press the X button on the interstitial test ad to close it
  5. immediately open the iOS control center (swipe down from the right side of the top edge of the screen)

Expected result: the ad closes and the OnAdClosed callback is triggered Actual result: the ad closes but the OnAdClosed callback is NOT triggered

Here are two videos:

Notes and findings:

  • on iOS, by default, opening the control center (or notifications, or multitasking) will pause the game and make it not in focus (can be seen by using MonoBehaviour.OnApplicationPause and MonoBehaviour.OnApplicationFocus)
  • by enabling the ‘Enable Custom Background Behaviours’ option (in Player Settings > Other Settings > Configuration), the game won’t be paused when the control center is opened, but it will lose focus (according to the two methods from the previous point); this bug still occurs even with this option enabled
  • settings the game to pause while an ad is running with MobileAds.SetiOSAppPauseOnBackground(true); does not solve this issue either; the same thing happens and the game remains paused
  • I don’t know if it is relevant, but this bug occurs with both test ads and real ads (in a launched product)
  • the example project uses a bare-bones implementation of AdMob, using the sample code from this repository and the official guide
  • I haven’t tested it, but I think this issue happens with reward ads as well (OnAdClosed and maybe even OnUserEarnedReward with proper timing)
  • the issue doesn’t seem to occur on Android devices by opening the notifications pull-down menu, might be because that doesn’t pause the game or the ad

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
emcmeemcommented, Jul 14, 2022

This problem is still not solved for me too

2reactions
NVentimigliacommented, Dec 23, 2021

@PokerDawg I implemented the suggested fix of wrapping the callback handler within ExecuteInUpdate(). The result looked correct to me (image below). I will be closing this issue, please feel free to reopen if there is something I missed or you are still stuck.

image image

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS Bug: Ad callbacks not triggering (reproducible)
iOS Bug : Ad callbacks not triggering (reproducible). 26 views.
Read more >
Admob's callback not firing everytime in Swift
I made an app in Swift with SwiftUI framework and SwiftUI App life cycle. ... The problem is that sometime the callback work,...
Read more >
Bug - Game may start with incorrect Orientation
We noticed that the bug may not have reproducible on an iPhone 13 with iOS 16.1.2, but it did occur when upgrading that...
Read more >
Apple Developer Forums
I am trying to automate Web app on iOS Safari for e2e test. Even though following code worked for emulator in iOS 17...
Read more >
Apple Developer Forums
Connect with fellow developers and Apple experts as you give and receive help on a wide variety of development topics, from implementing new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found