NativeAd

@objc(YMANativeAd)
@MainActor
public protocol NativeAd : NSObjectProtocol

The protocol provides methods for managing an ad and getting the values of the ad assets.

  • Type of native ad. For acceptable values, see NativeAdType.

    Declaration

    Swift

    @MainActor
    var adType: NativeAdType { get }
  • An object implementing the NativeAdDelegate protocol that receives events triggered by the user’s interaction with the ad.

    Declaration

    Swift

    @MainActor
    var delegate: NativeAdDelegate? { get set }
  • ads

    An array with nested ads.

    Declaration

    Swift

    @MainActor
    var ads: [NativeAd] { get }
  • Information about the ad.

    Declaration

    Swift

    @MainActor
    var adInfo: AdInfo? { get }
  • An object with ad assets.

    Declaration

    Swift

    @MainActor
    func adAssets() -> NativeAdAssets

    Return Value

    Returns an object containing the ad assets.

  • Loads images if manual loading is selected.

    Warning

    All images are cached, but they can be deleted at any time, so you need to call this method before every ad impression.

    Declaration

    Swift

    @MainActor
    func loadImages(completionHandler: (@MainActor () -> Void)?)

    Parameters

    completionHandler

    The completion handler to be called when the image loading is finished.

  • Sets values of all ad assets to native ad view, installs impression and click handlers.

    Declaration

    Swift

    @objc(bindWithAdView:error:)
    @MainActor
    func bind(with adView: NativeAdView) throws

    Parameters

    adView

    NativeAdView with views for ad assets.

    error

    Binding error.

    Return Value

    true if binding succeeded, otherwise false.

  • Sets values of all ad assets to native ad view, installs impression and click handlers. The method is intended for use in Third-Party Mediation.

    Declaration

    Swift

    @objc(bindAdToView:viewData:error:)
    @MainActor
    func bindAd(to view: UIView, viewData: NativeAdViewData) throws

    Parameters

    view

    Root ad view, superview for all asset views.

    viewData

    NativeAdViewData with views for ad assets.

    error

    Binding error.

    Return Value

    true if binding succeeded, otherwise false.

  • loadImages() Extension method

    Loads images if manual loading is selected.

    Warning

    All images are cached, but they can be deleted at any time, so you need to call this method before every ad impression.

    Declaration

    Swift

    @MainActor
    func loadImages()
  • loadImages() Extension method, asynchronous

    Asynchronously loads images if manual loading is selected.

    Warning

    All images are cached, but they can be deleted at any time, so you need to call this method before every ad impression.

    Declaration

    Swift

    @MainActor
    func loadImages() async