MPBannerCustomEventDelegate

@protocol MPBannerCustomEventDelegate <NSObject>

Instances of your custom subclass of MPBannerCustomEvent will have an MPBannerCustomEventDelegate delegate. You use this delegate to communicate events ad events back to the MoPub SDK.

When mediating a third-party ad network, it is important to call as many of these methods as accurately as possible. Not all ad networks support all these events, and some support different events. It is your responsibility to find an appropriate mapping between the ad network’s events and the callbacks defined on MPBannerCustomEventDelegate.

Public Methods

-/viewControllerForPresentingModalView

  • Description: The view controller instance to use when presenting modals. Returns the same view controller that you specify when implementing the MPAdViewDelegate protocol.

  • Declaration:

    - (UIViewController *)viewControllerForPresentingModalView;
    
  • Parameters: None.

-/location

  • Description: The user’s current location. You may use this to inform third-party ad networks of the user’s location. This method provides the location that was passed into the parent MPAdView. The MoPub SDK does not automatically request the user’s location. It is your responsibility to pass the location into MPAdView.

  • Declaration:

    - (CLLocation *)location;
    
  • Parameters: None.

-/bannerCustomEvent:didLoadAd:

  • Description: Call this method immediately after an ad loads successfully. Important: Your custom event subclass must call this method when it successfully loads an ad. Failure to do so will disrupt the mediation waterfall and cause future ad requests to stall.

  • Declaration:

    - (void)bannerCustomEvent:(MPBannerCustomEvent *)event didLoadAd:(UIView *)ad;
    
  • Parameters:

    • event: Pass self to allow the MoPub SDK to associate this event with the correct instance of your custom event.
    • ad: The UIView representing the banner ad. This view will be inserted into the MPAdView and presented to the user by the MoPub SDK.

-/bannerCustomEvent:didFailToLoadAdWithError:

  • Description: Call this method immediately after an ad fails to load. Important: Your custom event subclass must call this method when it fails to load an ad. Failure to do so will disrupt the mediation waterfall and cause future ad requests to stall.

  • Declaration:

    - (void)bannerCustomEvent:(MPBannerCustomEvent *)event
        didFailToLoadAdWithError:(NSError *)error;
    
  • Parameters:

    • event: Pass self to allow the MoPub SDK to associate this event with the correct instance of your custom event.
    • error: Optional. An error describing the failure.

-/bannerCustomEventWillBeginAction:

  • Description: Call this method when the user taps on the banner ad. This method is optional. When automatic click and impression tracking is enabled (the default) this method will track a click (the click is guaranteed to only be tracked once per ad). Important: If you call -bannerCustomEventWillBeginAction:, you must also call -bannerCustomEventDidFinishAction: at a later point.

  • Declaration:

    - (void)bannerCustomEventWillBeginAction:(MPBannerCustomEvent *)event;
    
  • Parameters:

    • event: Pass self to allow the MoPub SDK to associate this event with the correct instance of your custom event.

-/bannerCustomEventDidFinishAction:

  • Description: Call this method when the user finishes interacting with the banner ad. For example, the user may have dismissed any modal content. This method is optional. Important: If you call -bannerCustomEventWillBeginAction:, you must also call -bannerCustomEventDidFinishAction: at a later point.

  • Declaration:

    - (void)bannerCustomEventDidFinishAction:(MPBannerCustomEvent *)event;
    
  • Parameters:

    • event: Pass self to allow the MoPub SDK to associate this event with the correct instance of your custom event.

-/bannerCustomEventWillLeaveApplication:

  • Description: Call this method when the banner ad will cause the user to leave the application. For example, the user may have tapped on a link to visit the App Store or Safari.

  • Declaration:

    - (void)bannerCustomEventWillLeaveApplication:(MPBannerCustomEvent *)event;
    
  • Parameters:

    • event: Pass self to allow the MoPub SDK to associate this event with the correct instance of your custom event.

Impression and Click Tracking

-/trackImpression

  • Description: Call this method to track an impression. Important: You should only call this method if you have opted out of automatic click and impression tracking. By default the MoPub SDK automatically tracks impressions. Important: In order to obtain accurate metrics, it is your responsibility to call trackImpression only once per ad.

  • Declaration:

    - (void)trackImpression;
    
  • Parameters: None.

-/trackClick

  • Description: Call this method to track a click. Important: You should only call this method if you have opted out of automatic click and impression tracking. By default the MoPub SDK automatically tracks clicks. Important: In order to obtain accurate metrics, it is your responsibility to call trackClick only once per ad.

  • Declaration:

    - (void)trackClick;
    
  • Parameters: None.

-/bannerCustomEventWillExpandAd:

  • Description: Call this method when the banner ad is expanding or resizing from its default size.

  • Declaration:

    - (void)bannerCustomEventWillExpandAd:(MPBannerCustomEvent *)event;
    
  • Parameters:

    • event: Pass self to allow the MoPub SDK to associate this event with the correct instance of your custom event.

-/bannerCustomEventDidCollapseAd:

  • Description: Call this method when the banner ad is collapsing back to its default size.

  • Declaration:

    - (void)bannerCustomEventDidCollapseAd:(MPBannerCustomEvent *)event;
    
  • Parameters:

    • event: Pass self to allow the MoPub SDK to associate this event with the correct instance of your custom event.

Last updated March 03, 2020

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2020 MoPub (a division of Twitter, Inc.)