MMNativeAd Class Reference

Inherits from MMAd : NSObject
Declared in MMNativeAd.h

Overview

The class representing a native advertisement, its content, and the associated actions.

When presenting a native advertisement, you are allowed to style the content as you see fit, but should not mix your native app elements with native advertising elements to avoid confusion.

– initWithPlacementId:adType:

Initializes a native ad placement.

- (nullable instancetype)initWithPlacementId:(NSString *)placementId adType:(NSString *)nativeAdType

Parameters

placementId

The identifier of the placement that is used by the server for selecting ad content.

nativeAdType

An NSString object which corresponds to a defined native type, for example, MMNativeAdTypeInline.

Return Value

The MMNativeAd object.

Discussion

Initializes a native ad placement.

Declared In

MMNativeAd.h

– initWithPlacementId:supportedTypes:

Initializes a native ad placement.

- (nullable instancetype)initWithPlacementId:(NSString *)placementId supportedTypes:(NSArray *)types

Parameters

placementId

The identifier of the placement that is used by the server for selecting ad content.

types

An array of NSString objects, each of which corresponds to a defined native type, for example, MMNativeAdTypeInline.

Return Value

The MMNativeAd object.

Discussion

Initializes a native ad placement.

Declared In

MMNativeAd.h

– load:

Requests a native ad, asynchronously.

- (void)load:(nullable MMRequestInfo *)requestInfo

Parameters

requestInfo

Additional targeting information relevant to this individual request.

Discussion

Requests a native ad, asynchronously.

Declared In

MMNativeAd.h

– invokeDefaultAction

Notify the MMNativeAd that the user has tapped in the app’s native ad presentation.

- (void)invokeDefaultAction

Discussion

Notify the MMNativeAd that the user has tapped in the app’s native ad presentation.

Use this method to invoke the default action for taps anywhere in the native ad container view controlled by the app.

Declared In

MMNativeAd.h

– fireImpression

Notify the MMNativeAd that the app’s native ad container view has been presented on screen and is viewable.

- (void)fireImpression

Discussion

Notify the MMNativeAd that the app’s native ad container view has been presented on screen and is viewable.

To ensure accurate reporting, is important to invoke this method when a valid impression has taken place.

MMAdSDK validates that required components have been accessed by the ad container, an error is logged otherwise.

Supported OpenRTB tracking:

MMNativeAdTypeInline fires the OpenRTB imptrackers if present in the native response. Note: jstracker is not supported because there is no webView associated with MMNativeAdTypeInline.

Declared In

MMNativeAd.h

– loadIntoLayoutFromBundle:

Load the current native ad into a pre-defined layout, loaded from the specified bundle. This method must be invoked from the main thread.

- (nullable UIView *)loadIntoLayoutFromBundle:(NSBundle *)bundle

Parameters

bundle

A bundle object containing nibs for layout, along with a layouts.plist descriptor. See the full documentation on constructing a layout bundle for details.

Return Value

An instance of the view loaded from the bundle, with its contents populated with the native ad, or nil if a view could not be loaded.

Discussion

Load the current native ad into a pre-defined layout, loaded from the specified bundle. This method must be invoked from the main thread.

Once a given ad is loaded into a layout, you should not access, display, or modify any of the views of the native ad. Impression firing is also handled by the layout, which may have additional logic associated with it by the layout designer.

Declared In

MMNativeAd.h

  delegate

The native ad’s delegate.

@property (nonatomic, weak, nullable) id<MMNativeAdDelegate> delegate

Discussion

The native ad’s delegate.

Declared In

MMNativeAd.h

  isValid

The state of the native ad components.

@property (nonatomic, readonly) BOOL isValid

Discussion

The state of the native ad components.

The value will be YES when all components are loaded, ready to use, and have not expired, NO otherwise. Be sure to test isValid before retrieving native ad content to ensure it has not expired.

Declared In

MMNativeAd.h

  type

The type of the native ad.

@property (nonatomic, readonly, nullable) NSString *type

Discussion

The type of the native ad.

Declared In

MMNativeAd.h

  disclaimer

The disclaimer text marking a visual element as an advertisement.

@property (nonatomic, readonly, nullable) UILabel *disclaimer

Discussion

The disclaimer text marking a visual element as an advertisement.

The text value must be displayed and should not be altered. Example disclosure language includes: “Sponsored by [brand]” or “Presented by [brand]”

Default attributes which may be may be altered by the user:

length - recommended maximum length of 25 characters for these defaults. width - set by sizeWithAttributes: for the default font font - systemFontOfSize: 8.0

Returns nil if this component is not available.

Declared In

MMNativeAd.h

– disclaimer:

The disclaimer text marking a visual element as an advertisement.

- (nullable UILabel *)disclaimer:(NSInteger)instanceId

Parameters

instanceId

represents which disclaimer instance to retrieve, starting from 1

Return Value

The disclaimer label for the ad, or nil if there is no disclaimer available.

Discussion

The disclaimer text marking a visual element as an advertisement.

The text value must be displayed and should not be altered. Example disclosure language includes: “Sponsored by [brand]” or “Presented by [brand]”

Default attributes which may be may be modified by the user:

length - recommended maximum length of 25 characters for these defaults. width - set by sizeWithAttributes: for the default font font - systemFontOfSize: 8.0

Declared In

MMNativeAd.h

  iconImageView

An imageView containing the icon image for the ad, with an associated gesture recognizer that invokes the associated action when the element is tapped.

@property (nonatomic, readonly, nullable) UIImageView *iconImageView

Discussion

An imageView containing the icon image for the ad, with an associated gesture recognizer that invokes the associated action when the element is tapped.

None of the content associated with this view or its actions should be altered in any way.

Default attributes which may be may be modified by the user:

size - The imageView size defaults to the size of the asset resource. The recommended approach is to set the frame of the imageView to the bounds of its superView, which has autoresizesSubviews=YES: nativeAd.iconImageView.frame = self.nativeAdContainer.iconImageView.bounds;

Returns nil if this component is not available.

Declared In

MMNativeAd.h

– iconImageView:

An imageView containing the icon image for the ad, with an associated gesture recognizer that invokes the associated action when the element is tapped.

- (nullable UIImageView *)iconImageView:(NSInteger)instanceId

Parameters

instanceId

represents which iconImageView instance to retrieve, starting from 1

Return Value

The icon imageView for the ad, or nil if there is no imageView available.

Discussion

An imageView containing the icon image for the ad, with an associated gesture recognizer that invokes the associated action when the element is tapped.

None of the content associated with this view or its actions should be altered in any way.

Default attributes which may be may be modified by the user:

size - The imageView size defaults to the size of the asset resource. The recommended approach is to set the frame of the imageView to the bounds of its superView, which has autoresizesSubviews=YES: nativeAd.iconImageView.frame = self.nativeAdContainer.iconImageView.bounds;

Returns nil if this component is not available.

Declared In

MMNativeAd.h

  mainImageView

An imageView containing the main image for the ad, with an associated gesture recognizer that invokes the associated action when the element is tapped.

@property (nonatomic, readonly, nullable) UIImageView *mainImageView

Discussion

An imageView containing the main image for the ad, with an associated gesture recognizer that invokes the associated action when the element is tapped.

None of the content associated with this view or its actions should be altered in any way.

Default attributes which may be may be modified by the user:

size - The imageView size defaults to the size of the asset resource. The recommended approach is to set the frame of the imageView to the bounds of its superView, which has autoresizesSubviews=YES: nativeAd.mainImageView.frame = self.nativeAdContainer.mainImageView.bounds;

Returns nil if this component is not available.

Declared In

MMNativeAd.h

– mainImageView:

An imageView containing the main image for the ad, with an associated gesture recognizer that invokes the associated action when the element is tapped.

- (nullable UIImageView *)mainImageView:(NSInteger)instance

Parameters

instance

represents which mainImageView instance to retrieve, starting from 1

Return Value

The main imageView for the ad, or nil if there is no imageView available.

Discussion

An imageView containing the main image for the ad, with an associated gesture recognizer that invokes the associated action when the element is tapped.

None of the content associated with this view or its actions should be altered in any way.

Default attributes which may be may be modified by the user:

size - The imageView size defaults to the size of the asset resource. The recommended approach is to set the frame of the imageView to the bounds of its superView, which has autoresizesSubviews=YES: nativeAd.mainImageView.frame = self.nativeAdContainer.mainImageView.bounds;

Returns nil if this component is not available.

Declared In

MMNativeAd.h

  body

Descriptive text for the ad.

@property (nonatomic, readonly, nullable) UILabel *body

Discussion

Descriptive text for the ad.

The text value must be displayed and should not be altered.

Default attributes which may be may be modified by the user:

length - recommended maximum length of 200 characters for these defaults. size - default body label size is (200.0, 60.0) font - systemFontOfSize: 9.0 number of lines - 5

Returns nil if this component is not available.

Declared In

MMNativeAd.h

– body:

Descriptive body text for the ad.

- (nullable UILabel *)body:(NSInteger)instanceId

Parameters

instanceId

represents which body instance to retrieve, starting from 1

Return Value

The body label for the ad, or nil if there is no body label available.

Discussion

Descriptive body text for the ad.

The text value must be displayed and should not be altered.

Default attributes which may be may be modified by the user:

length - recommended maximum length of 200 characters for these defaults. size - default body label size is (200.0, 60.0) font - systemFontOfSize: 9.0 number of lines - 5

Returns nil if this component is not available.

Declared In

MMNativeAd.h

  title

The title label of the ad.

@property (nonatomic, readonly, nullable) UILabel *title

Discussion

The title label of the ad.

The text value must be displayed and should not be altered.

Default attributes which may be may be modified by the user:

length - recommended maximum length of 15 characters for these defaults. width - set by sizeWithAttributes: for the default font font - systemFontOfSize: 16.0

Returns nil if this component is not available.

Declared In

MMNativeAd.h

– title:

The title label of the ad.

- (nullable UILabel *)title:(NSInteger)instanceId

Parameters

instanceId

represents which title instance to retrieve, starting from 1

Return Value

The title label for the ad, or nil if there is no title label available.

Discussion

The title label of the ad.

The text value must be displayed and should not be altered.

Default attributes which may be may be modified by the user:

length - recommended maximum length of 15 characters for these defaults. width - set by sizeWithAttributes: for the default font font - systemFontOfSize: 16.0

Returns nil if this component is not available.

Declared In

MMNativeAd.h

  callToActionButton

The call to action button which invokes the associated main action for an ad.

@property (nonatomic, readonly, nullable) UIButton *callToActionButton

Discussion

The call to action button which invokes the associated main action for an ad.

None of the content associated with this button or its actions should be altered.

Default attributes which may be may be modified by the user:

length - recommended maximum length of 5 characters for these defaults. width - set by sizeWithAttributes: for the default font font - systemFontOfSize: 10.0

Returns nil if this component is not available.

Declared In

MMNativeAd.h

– callToActionButton:

The call-to-action button which invokes the associated main action for an ad.

- (nullable UIButton *)callToActionButton:(NSInteger)instance

Parameters

instance

represents which call-to-action button instance to retrieve, starting from 1

Return Value

The call-to-action label for the ad, or nil if there is no call-to-action button available.

Discussion

The call-to-action button which invokes the associated main action for an ad.

None of the content associated with this button or its actions should be altered.

Default attributes which may be may be modified by the user:

length - recommended maximum length of 5 characters for these defaults. width - set by sizeWithAttributes: for the default font font - systemFontOfSize: 10.0

Returns nil if this component is not available.

Declared In

MMNativeAd.h

  rating

The rating label for the native ad.

@property (nonatomic, readonly, nullable) UILabel *rating

Discussion

The rating label for the native ad.

The text value must be displayed and should not be altered.

Default attributes which may be may be modified by the user:

length - recommended maximum length of 15 characters for these defaults. width - set by sizeWithAttributes: for the default font font - systemFontOfSize: 10.0

Returns nil if this component is not available.

Declared In

MMNativeAd.h

– rating:

The rating label of the ad. The text value must be displayed and should not be altered.

- (nullable UILabel *)rating:(NSInteger)instance

Parameters

instance

The instance to retrieve, indexed from 1.

Return Value

The rating label for the ad, or nil if there is no rating label available.

Discussion

The rating label of the ad. The text value must be displayed and should not be altered.

The text value must be displayed and should not be altered.

Default attributes which may be may be modified by the user:

length - recommended maximum length of 15 characters for these defaults. width - set by sizeWithAttributes: for the default font font - systemFontOfSize: 10.0

Returns nil if this component is not available.

Declared In

MMNativeAd.h