When you make an ad request using the Google Mobile Ads SDK , you’re probably setting an AdListener or GADBannerViewDelegate to listen for ad events. The click events for these listeners are slightly different on Android and iOS, so today we’ll take a deeper look at what events get invoked when an ad click:
opens an overlay, for example an in-app browser
launches an external application, for example an external browser or app store
Ad Opens an Overlay
Here are the ad events that get called when an ad opens an overlay:
Event
Android Callback(s)
iOS Callback(s)
Ad Opens Overlay
onAdOpened
adViewWillPresentScreen
Ad Overlay is Closed
onAdClosed
adViewWillDismissScreen adViewDidDismissScreen
These events are pretty straightforward. When the ad overlay opens, you get a single callback. When the ad overlay closes, Android notifies you the moment the event happens, while iOS notifies you right before and after the event happens.
Ad Launches an External Application
When an ad launches an external application, the ad events are slightly different:
Event
Android Callback(s)
iOS Callback(s)
Ad Launches External App
onAdOpened onAdLeftApplication
adViewWillLeaveApplication
User relaunches App
onAdClosed
-----
Notice how on Android you still get the onAdOpened
and onAdClosed
events even if an ad leaves an application. But on iOS, the adViewWillPresentScreen
and adViewWillDismissScreen/adViewDidDismissScreen
events are only invoked when presenting and dismissing modal views.
So how do you know when the user returns to your iOS app? You can listen for the applicationWillEnterForeground delegate method that iOS provides.
Testing The Different Click Behaviors
Hopefully you’re already requesting test ads during application development. If you’re making test requests, you should already see these ads showing up in your development environment:
On iOS, you can use these ads to test both ad click behaviors. If you click the banner, the Google Mobile Ads SDK will launch an external web browser and call adViewWillLeaveApplication
. If you click the icon in the bottom-left corner of the ad, the SDK will launch an overlay and adViewWillPresentScreen
will get called.
Hopefully this clears up any confusion regarding any ad click events. If you have any additional questions, we’ll field them on our forum . You can also find us on Google+ .
- Eric Leichtenschlag , Mobile Ads Developer Relations