SASNativeAdMediaViewDelegate

Objective-C

@protocol SASNativeAdMediaViewDelegate <NSObject>

Swift

protocol SASNativeAdMediaViewDelegate

The delegate of a SASNativeAdMediaView object must adopt the SASNativeAdMediaViewDelegate protocol.

Note

This delegate is only media related. For example a click, which is related to the SASNativeAd binded to the SASNativeAdMediaView will not trigger any methods of the SASNativeAdMediaViewDelegate protocol.
  • Notifies the delegate that the SASNativeAdMediaView failed to load its media.

    This can happen when the user’s connection is interrupted before downloading the media. In this case you might want to:

    • refresh the ad view
    • dismiss the ad view
    • or just remove the media view from the view hierarchy and switch to another native ad UI.

    Declaration

    Objective-C

    - (void)nativeAdMediaView:(nonnull SASNativeAdMediaView *)mediaView
        didFailToLoadMediaWithError:(nonnull NSError *)error;

    Swift

    optional func nativeAdMediaView(_ mediaView: Any!, didFailToLoadMediaWithError error: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object informing the delegate about the failure.

    error

    An error informing the delegate about the cause of the failure.

  • Notifies the delegate that the media from the current SASNativeAd has been loaded and displayed into the SASNativeAdMediaView.

    Declaration

    Objective-C

    - (void)nativeAdMediaViewDidLoadMedia:(nonnull SASNativeAdMediaView *)mediaView;

    Swift

    optional func nativeAdMediaViewDidLoadMedia(_ mediaView: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object informing the delegate about the creative being loaded.

  • Notifies the delegate that a modal view will be presented to display the media in fullscreen.

    Declaration

    Objective-C

    - (void)nativeAdMediaViewWillPresentFullscreenModalMedia:
        (nonnull SASNativeAdMediaView *)mediaView;

    Swift

    optional func nativeAdMediaViewWillPresentFullscreenModalMedia(_ mediaView: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object informing the delegate about the upcoming modal presentation.

  • Notifies the delegate that a modal view has been presented to display the media in fullscreen.

    Declaration

    Objective-C

    - (void)nativeAdMediaViewDidPresentFullscreenModalMedia:
        (nonnull SASNativeAdMediaView *)mediaView;

    Swift

    optional func nativeAdMediaViewDidPresentFullscreenModalMedia(_ mediaView: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object informing the delegate about the finished modal presentation.

  • Notifies the delegate that a modal view displaying the media in fullscreen is about to dismiss.

    Declaration

    Objective-C

    - (void)nativeAdMediaViewWillCloseFullscreenModalMedia:
        (nonnull SASNativeAdMediaView *)mediaView;

    Swift

    optional func nativeAdMediaViewWillCloseFullscreenModalMedia(_ mediaView: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object informing the delegate about the upcoming modal dismissal.

  • Notifies the delegate that a modal view displaying the media in fullscreen has been dismissed.

    Declaration

    Objective-C

    - (void)nativeAdMediaViewDidCloseFullscreenModalMedia:
        (nonnull SASNativeAdMediaView *)mediaView;

    Swift

    optional func nativeAdMediaViewDidCloseFullscreenModalMedia(_ mediaView: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object informing the delegate about the finished modal dismissal.

Native Audio Playback

  • Tells the MediaView if it should handle AVAudioSession on its own when playing native (audio/video) ads.

    Implement this method and return NO if you want to override MediaView’s behavior with AVAudioSession.

    Use the nativeAdMediaViewWillPlayAudio: and nativeAdMediaViewDidFinishPlayingAudio: methods to implement your own behavior.

    Warning

    Disabling AVAudioSession handling can prevent the SDK to change the volume for a creative or to display mute/unmute buttons on some formats.

    Declaration

    Objective-C

    - (BOOL)nativeAdMediaViewShouldHandleAudioSession:
        (nonnull SASNativeAdMediaView *)mediaView;

    Swift

    optional func nativeAdMediaViewShouldHandleAudioSession(_ mediaView: Any!) -> Any!

    Parameters

    mediaView

    The SASNativeAdMediaView object which is going to interact with AVAudioSession.

    Return Value

    YES (default if not implemented) to let the MediaView handle AVAudioSession for native videos, NO to implement your own behavior.

  • Notifies the delegate that the MediaView will start playing native audio.

    Implement this method if you want to know when a MediaView starts playing native audio (e.g. from a native video).

    This is useful if you want to pause your own audio, change the shared AudioSession or trigger other custom behavior.

    Declaration

    Objective-C

    - (void)nativeAdMediaViewWillPlayAudio:
        (nonnull SASNativeAdMediaView *)mediaView;

    Swift

    optional func nativeAdMediaViewWillPlayAudio(_ mediaView: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object which is going to play audio.

  • Notifies the delegate that the SASNativeAdMediaView finished playing native audio.

    Implement this method if you want to know when a MediaView finishes playing native audio.

    This is useful if you want to resume your own audio, change the shared AudioSession or trigger other custom behavior.

    Declaration

    Objective-C

    - (void)nativeAdMediaViewDidFinishPlayingAudio:
        (nonnull SASNativeAdMediaView *)mediaView;

    Swift

    optional func nativeAdMediaViewDidFinishPlayingAudio(_ mediaView: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object which finished playing audio.

Native video playback

  • Notifies the delegate that the SASNativeAdMediaView has generated a video event.

    Implement this method if you want to know when some events are reached when a video is played.

    This can be useful if you want to implement specific app behavior when the user interact with the video or when he reach a certain point of the video.

    Note

    This method will only be triggered by native creatives, not by HTML based creatives.

    Declaration

    Objective-C

    - (void)nativeAdMediaView:(nonnull SASNativeAdMediaView *)mediaView
            didSendVideoEvent:(SASVideoEvent)videoEvent;

    Swift

    optional func nativeAdMediaView(_ mediaView: Any!, didSendVideoEvent videoEvent: Any!)

    Parameters

    mediaView

    The SASNativeAdMediaView object currently playing the video.

    videoEvent

    The video event that has been triggered.