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
NativeAdDelegateprotocol that receives events triggered by the user’s interaction with the ad.Declaration
Swift
@MainActor var delegate: NativeAdDelegate? { get set } -
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() -> NativeAdAssetsReturn 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
completionHandlerThe 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) throwsParameters
adViewNativeAdViewwith views for ad assets.errorBinding error.
Return Value
trueif binding succeeded, otherwisefalse. -
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) throwsParameters
viewRoot ad view, superview for all asset views.
viewDataNativeAdViewDatawith views for ad assets.errorBinding error.
Return Value
trueif binding succeeded, otherwisefalse. -
loadImages()Extension methodLoads 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, asynchronousAsynchronously 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