MPNativeAdRendering

@protocol MPNativeAdRendering <NSObject>

The MPNativeAdRendering protocol provides methods for displaying ad content in custom view classes. It can be used for both static native ads and native video ads. If you are serving native video ads, you must implement nativeVideoView.

Public Methods

-/nativeMainTextLabel

  • Description: Returns the UILabel that your view is using for the main text.

  • Declaration:

    - (UILabel *)nativeMainTextLabel;
    
  • Parameters: None.

-/nativeTitleTextLabel

  • Description: Returns the UILabel that your view is using for the title text.

  • Declaration:

    - (UILabel *)nativeTitleTextLabel;
    
  • Parameters: None.

-/nativeIconImageView

  • Description: Returns the UIImageView that your view is using for the icon image.

  • Declaration:

    - (UIImageView *)nativeIconImageView;
    
  • Parameters: None.

-/nativeMainImageView

  • Description: Returns the UIImageView that your view is using for the main image.

  • Declaration:

    - (UIImageView *)nativeMainImageView;
    
  • Parameters: None.

-/nativeSponsoredByCompanyTextLabel

  • Description: Returns the UILabel that your view is using for text indicating the sponsor that sponsored the ad. Sometimes sponsor information is not included with the advertisement; in that case, MoPub will set the label’s text to empty string and the label’s hidden property to YES. Please configure your view to be ready for this possibility.

  • Declaration:

    - (UILabel *)nativeSponsoredByCompanyTextLabel;
    
  • Parameters: None.

+/localizedSponsoredByTextWithSponsorName:

  • Description: Specifies custom text for nativeSponsoredByCompanyTextLabel, primarily to be used for localization, but also can be used for custom copy, such as “Brought to you by Example” rather than the default “Sponsored by Example”. If this method is not implemented, or is implemented to return nil or empty string, MoPub will use the default “Sponsored by Example”. Returns an assembled string containing sponsorName, indicating something to the effect of “Sponsored by”.

  • Declaration:

    + (NSString *)localizedSponsoredByTextWithSponsorName:(NSString *)sponsorName;
    
  • Parameters:

    • sponsorName: The name of the sponsor who sponored the native ad.

-/nativeVideoView

  • Description: Returns the UIView that your view is using to hold the video. Should only be implemented when you are serving video ads.

  • Declaration:

    - (UIView *)nativeVideoView;
    
  • Parameters: None.

-/nativeCallToActionTextLabel

  • Description: Returns the UILabel that your view is using for the call to action (CTA) text.

  • Declaration:

    - (UILabel *)nativeCallToActionTextLabel;
    
  • Parameters: None.

-/nativePrivacyInformationIconImageView

  • Description: Returns the UIImageView that your view is using for the privacy information icon.

  • Declaration:

    - (UIImageView *)nativePrivacyInformationIconImageView;
    
  • Parameters: None.

-/layoutStarRating:

  • Description: Called if the ad contains a star rating. Implement this method if you expect and wish to display a star rating.

  • Declaration:

    - (void)layoutStarRating:(NSNumber *)starRating;
    
  • Parameters:

    • starRating: An NSNumber that is a float in the range of 0.0f and 5.0f.

-/layoutCustomAssetsWithProperties:imageLoader:

  • Description: This method is used to insert your custom native ad elements into your view. It will be called when your ad view is added to the view hierarchy.

  • Declaration:

    - (void)layoutCustomAssetsWithProperties:(NSDictionary *)customProperties
                               imageLoader:
                                   (MPNativeAdRenderingImageLoader *)imageLoader;
    
  • Parameters:

    • customProperties: Dictionary that contains custom native ad elements.
    • imageLoader: Use this object to load your custom images by calling loadImageForURL:intoImageView:.

+/nibForAd

  • Description: Specifies a nib object containing a view used to render ads if you want to use a nib object to render ads. Returns an initialized UINib object. This is not allowed to be nil.

  • Declaration:

    + (UINib *)nibForAd;
    
  • Parameters: None.

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.)