SASNativeAdViewDelegate

Objective-C

@protocol SASNativeAdViewDelegate <NSObject>

Swift

protocol SASNativeAdViewDelegate : NSObjectProtocol

SASNativeAdView delegate.

  • Called when the native ad view has loaded an ad successfully.

    Declaration

    Objective-C

    - (void)nativeAdView:(nonnull SASNativeAdView *)nativeAdView
         didLoadWithInfo:(nonnull SASAdInfo *)adInfo
          nativeAdAssets:(nonnull SASNativeAdAssets *)nativeAdAssets;

    Swift

    func nativeAdView(_ nativeAdView: SASNativeAdView, didLoadWith adInfo: SASAdInfo, nativeAdAssets: SASNativeAdAssets)

    Parameters

    nativeAdView

    The instance of SASNativeAdView calling the delegate.

    adInfo

    The instance of SASAdInfo related to the loaded native ad.

    nativeAdAssets

    The assets of the loaded native ad that are going to be rendered by the native ad view.

  • Called when the native ad view fails to load the ad.

    Declaration

    Objective-C

    - (void)nativeAdView:(nonnull SASNativeAdView *)nativeAdView
        didFailToLoadWithError:(nonnull NSError *)error;

    Swift

    func nativeAdView(_ nativeAdView: SASNativeAdView, didFailToLoad error: any Error)

    Parameters

    nativeAdView

    The instance of SASNativeAdView calling the delegate.

    error

    The error preventing the native ad from being loaded.

  • Called when a valid click is registered on the native ad view.

    Declaration

    Objective-C

    - (void)nativeAdViewClicked:(nonnull SASNativeAdView *)nativeAdView;

    Swift

    optional func nativeAdViewClicked(_ nativeAdView: SASNativeAdView)

    Parameters

    nativeAdView

    The instance of SASNativeAdView calling the delegate.

  • Called when the native ad requests to be closed.

    Note

    Some ad formats might want to close the native ad by themself. It is the app responsability to actually close the native ad, aka to remove it from the views’ hierarchy. If the app does nothing or does not implement this delegate, the ad will not be closed.

    Declaration

    Objective-C

    - (void)nativeAdViewDidRequestClose:(nonnull SASNativeAdView *)nativeAdView;

    Swift

    optional func nativeAdViewDidRequestClose(_ nativeAdView: SASNativeAdView)

    Parameters

    nativeAdView

    The instance of SASNativeAdView requesting to be closed.

  • Called when a custom layout is requested in order to render the native ad.

    Implementing this method is optional: default layouts will be used if this method is not implemented or if the method returns nil.

    Declaration

    Objective-C

    - (nullable SASNativeAdViewBinder *)nativeAdView:
                                            (nonnull SASNativeAdView *)nativeAdView
                   didRequestBinderForNativeAdAssets:
                       (nonnull SASNativeAdAssets *)nativeAdAssets;

    Swift

    optional func nativeAdView(_ nativeAdView: SASNativeAdView, didRequestBinderFor nativeAdAssets: SASNativeAdAssets) -> SASNativeAdViewBinder?

    Parameters

    nativeAdView

    The instance of SASNativeAdView calling the delegate.

    nativeAdAssets

    A native ad assets instance related to this ad that can be used to customize the layout if needed. Please note that the SDK will not update your layout, therefore missing assets can lead to empty spaces. It is your app responsibility to adjust your layout to avoid blank spaces.

    Return Value

    A native ad view binder instance that will be used by the SDK to render the ad, or nil to use the default layout of the SDK.