MPNativeCustomEvent /5.0.0

@interface MPNativeCustomEvent : NSObject

The MoPub iOS SDK mediates third-party native ad networks using mediation adapters. mediation adapters are responsible for instantiating and manipulating native ad objects in the third-party SDK and translating and communicating events from those objects back to the MoPub SDK by notifying a delegate.

MPNativeCustomEvent is a base class for mediation adapters that support native ads. By implementing subclasses of MPNativeCustomEvent you can enable the MoPub SDK to support a variety of third-party ad networks.

Your implementation should create an MPNativeAd object using an appropriate MPNativeAdAdapter for your network. Your mediation adapter should also call the appropriate MPNativeCustomEventDelegate methods.

Public Properties

Communicating with the MoPub SDK

MPNativeCustomEventDelegate/delegate /+5.0.0

  • Description: The MPNativeCustomEventDelegate receives messages concerning the status of loading a native ad. The delegate object defines several methods that you should call in order to inform MoPub of the progress of your mediation adapter.

  • Declaration:

    @property (readwrite, nonatomic) id<MPNativeCustomEventDelegate> delegate;
    
  • Parameters: None.

NSDictionary/localExtras /+5.4.0

  • Description: An optional dictionary containing extra local data.

  • Declaration:

    @property (readwrite, copy, nonatomic) NSDictionary *localExtras;
    
  • Parameters: None.

Public Methods

Requesting a Native Ad

- /requestAdWithCustomEventInfo:info: /+5.0.0-5.10.0

  • Description: DEPRECATED AS OF v.5.10.0. Instead use - /requestAdWithCustomEventInfo:info:adMarkup:

    Called when the MoPub SDK requires a new native ad. When the MoPub SDK receives a response indicating it should load a mediation adapter, it will send this message to your mediation adapter class. Your implementation should load a native ad from a third-party ad network.

  • Declaration:

    - (void)requestAdWithCustomEventInfo:(NSDictionary *)info;
    
  • Parameters:

    • info: A dictionary containing additional custom data associated with a given mediation adapter request. This data is configurable on the MoPub website, and may be used to pass dynamic information, such as publisher IDs.

- /requestAdWithCustomEventInfo:info:adMarkup: /+5.10.0

  • Description: Called when the MoPub SDK requires a new native ad. When the MoPub SDK receives a response indicating it should load a mediation adapter, it will send this message to your mediation adapter class. Your implementation should load a native ad from a third-party ad network.

  • Declaration:

    - (void)requestAdWithCustomEventInfo:(NSDictionary *)info
                              adMarkup:(NSString *)adMarkup;
    
  • Parameters:

    • info: A dictionary containing additional custom data associated with a given mediation adapter request. This data is configurable on the MoPub website, and may be used to pass dynamic information, such as publisher IDs.

    • adMarkup: An optional ad markup to use.

Caching Image Resources

-/precacheImagesWithURLs:completionBlock: /+5.0.0

  • Description: Downloads and pre-caches images. If your ad network does not provide built-in support for image caching, you may invoke this method in your mediation adapter implementation to pre-cache image assets. If you do call this method, you should wait until the completion block is called before invoking the appropriate success or failure callbacks on the MPNativeCustomEventDelegate.

  • Declaration:

    - (void)precacheImagesWithURLs:(NSArray *)imageURLs
                 completionBlock:(void (^)(NSArray *))completionBlock;
    
  • Parameters:

    • imageURLs: An array of NSURL objects representing image resource locations.

    • completionBlock: A block that will be called after all download operations are complete. If any image downloads do not complete successfully, the errors parameter will contain error information about the failures.

Last updated July 10, 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.)