Skip to end of metadata
Go to start of metadata

Receive Ad View Status Events

This page has instructions on how to receive ad view status events from our SDK. You can use these events to determine from your app when an ad has been clicked, whether it's in an expanded state, and more.

Android

In order to receive status events during the life cycle of the ad view, you must implement the AdListener interface and attach it to the ad view. Its methods are:

  • void onAdClicked(AdView adView): Called when an ad is clicked.

  • void onAdClicked(adView, clickUrl): Called when an ad is clicked and allows you to determine how the value of the click_url string in the bid response will be handled.
  • void onAdCollapsed(AdView adView): Called when an ad is closed/unexpanded, for example if the user has stopped interacting with the ad.

  • void onAdExpanded(AdView adView): Called when an ad expands due to user interaction.

  • void onAdLoaded(AdView adView): Called when an ad has successfully been loaded from the server.

  • void onAdLoaded(NativeAdResponse nativeAdResponse): Called when an ad has successfully been loaded from the server. Used for Banner Native ads.
  • void onAdRequestFailed(AdView adView, ResultCode errorCode): Called when an ad request has failed.

The example below implements this interface:

We can see the results in LogCat:

iOS

In order to receive status events during the life cycle of the ad view, you must implement the ANAdDelegate protocol. Its methods are:

  • (void)adDidReceiveAd:(id)ad; Sent when Banner or Video ad content has been successfully retrieved from the server.
  • (void)ad:(id)loadInstance didReceiveNativeAd:(id)nativeAdResponse; Sent when Native ad content has been successfully retrieved from the server.
  • (void)ad:(id)ad requestFailedWithError:(NSError *)error: Sent when the ad request to the server has failed.

  • (void)adWasClicked:(id)ad: Sent when the ad is clicked by the user.

  • ( void )adWasClicked:(id)ad withURL:(NSString *)urlString: Sent when the ad is clicked by the user and allows you to determine how the value of the click_url string in the bid response will be handled.
  • (void)adWillClose:(id)ad: Sent when the ad view is about to close.

  • (void)adDidClose:(id)ad: Sent when the ad view has finished closing.

  • (void)adWillPresent:(id)ad: Sent when the ad is clicked, and the SDK is about to open inside the in-SDK browser (a WebView). If you would prefer that ad clicks open the native browser instead, set opensInNativeBrowser to true.

  • (void)adDidPresent:(id)ad: Sent when the ad has finished being viewed using the in-SDK browser.

  • (void)adWillLeaveApplication:(id)ad: Sent when the ad is about to leave the app; this can happen if you have opensInNativeBrowser set to true, for example.

The example below implements this protocol:

  • No labels