SASBannerViewDelegate
Objective-C
@protocol SASBannerViewDelegate <NSObject>
Swift
protocol SASBannerViewDelegate : NSObjectProtocol
Protocol that must be implemented by SASBannerView delegate.
-
Notifies the delegate that the ad data has been received.
Note
The ad creative is not loaded and/or displayed at this point.
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView didDownloadAd:(nonnull SASAd *)ad;
Swift
optional func bannerView(_ bannerView: SASBannerView, didDownloadAd ad: SASAd)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
ad
A SASAd object.
-
Notifies the delegate that the creative from the current ad has been loaded and displayed.
Declaration
Objective-C
- (void)bannerViewDidLoad:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewDidLoad(_ bannerView: SASBannerView)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Notifies the delegate that the SASBannerView failed to download the ad.
This can happen when the user’s connection is interrupted before downloading the ad or if the ad is invalid.
Note
Remember to remove the SASBannerView instance from its superview if necessary.
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView didFailToLoadWithError:(nonnull NSError *)error;
Swift
optional func bannerView(_ bannerView: SASBannerView, didFailToLoadWithError error: any Error)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
error
An error informing the delegate about the cause of the failure.
-
Notifies the delegate that the expandable SASBannerView did collapse.
This can happen:
- if the user tapped the toggle button to close the ad,
when the ad’s display duration is elapsed.
Declaration
Objective-C
- (void)bannerViewDidCollapse:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewDidCollapse(_ bannerView: SASBannerView)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Notifies the delegate that a modal view will appear to display the ad’s landing page.
Declaration
Objective-C
- (void)bannerViewWillPresentModalView:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewWillPresentModalView(_ bannerView: SASBannerView)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Notifies the delegate that the previously open modal view will be dismissed.
Declaration
Objective-C
- (void)bannerViewWillDismissModalView:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewWillDismissModalView(_ bannerView: SASBannerView)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Deprecated
Use ‘bannerView:didClickWithURL:’ instead
Asks the delegate whether the SDK should handles the opening action for the provided URL.
You can implement this method if you want to process some URLs yourself, for instance to make an in app redirection.
Note
Please note that click pixels will be sent, even if you choose to handle a particular URL yourself.
Note
This method is deprecated and will be removed in future releases. Publishers should not interfere client-side with clicks to avoid counting issues. However, if you still want to be warned is case of click, please implement bannerView:didClickWithURL: delegate method.
Declaration
Objective-C
- (BOOL)bannerView:(nonnull SASBannerView *)bannerView shouldHandleURL:(nonnull NSURL *)URL;
Swift
optional func bannerView(_ bannerView: SASBannerView, shouldHandle URL: URL) -> Bool
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
URL
The URL that will be called.
Return Value
YES if the Smart Display SDK should handle the URL, NO if the app should do it manually.
-
Notifies the delegate when a click is performed on the banner ad.
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView didClickWithURL:(nonnull NSURL *)URL;
Swift
optional func bannerView(_ bannerView: SASBannerView, didClickWith URL: URL)
Parameters
bannerView
The instance of SASBannerView.
URL
The URL that is called.
-
Notifies the delegate that the banner view is about to be resized.
Note
This method is not only called the first time an ad creative is resized, but also when the user rotates the device.
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView willResizeWithFrame:(CGRect)frame;
Swift
optional func bannerView(_ bannerView: SASBannerView, willResizeWithFrame frame: CGRect)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
frame
The frame of the ad view before resizing it.
-
Notifies the delegate that the banner view was resized.
Note
This method is not only called the first time an ad creative is resized, but also when the user rotates the device.
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView didResizeWithFrame:(CGRect)frame;
Swift
optional func bannerView(_ bannerView: SASBannerView, didResizeWithFrame frame: CGRect)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
frame
The frame of the ad view after resizing it.
-
Notifies the delegate that the banner view was resized.
Declaration
Objective-C
- (void)bannerViewDidFailToResize:(nonnull SASBannerView *)bannerView error:(nonnull NSError *)error;
Swift
optional func bannerViewDidFail(toResize bannerView: SASBannerView, error: any Error)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
error
The error that prevented the banner from being resized
-
Notifies the delegate that the resized banner was closed (i.e. is back in its original container).
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView didCloseResizeWithFrame:(CGRect)frame;
Swift
optional func bannerView(_ bannerView: SASBannerView, didCloseResizeWithFrame frame: CGRect)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
frame
The frame of the ad view after closing it.
-
Notifies the delegate that the banner view is about to be expanded.
Note
This method is not only called the first time an ad creative is expanded, but also when the user rotates the device.
Declaration
Objective-C
- (void)bannerViewWillExpand:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewWillExpand(_ bannerView: SASBannerView)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Notifies the delegate that the banner view was expanded.
Warning
This method is not only called the first time an ad creative is expanded, but also when the user rotates the device.
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView didExpandWithFrame:(CGRect)frame;
Swift
optional func bannerView(_ bannerView: SASBannerView, didExpandWithFrame frame: CGRect)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
frame
The frame of the ad view after expanding.
-
Notifies the delegate that the expanded banner is about to be closed (i.e. will be back in its original container).
Declaration
Objective-C
- (void)bannerViewWillCloseExpand:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewWillCloseExpand(_ bannerView: SASBannerView)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Notifies the delegate that the expanded banner was closed (i.e. is back in its original container).
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView didCloseExpandWithFrame:(CGRect)frame;
Swift
optional func bannerView(_ bannerView: SASBannerView, didCloseExpandWithFrame frame: CGRect)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
frame
The frame of the ad view after closing.
-
Notifies the delegate that the banner view received a message from the MRAID creative.
Creatives can send messages using mraid.sasSendMessage(“message”). These messages are sent to the ad view delegate by the SDK.
Note
this method IS NOT PART of MRAID 2.0 specification.
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView didReceiveMessage:(nonnull NSString *)message;
Swift
optional func bannerView(_ bannerView: SASBannerView, didReceiveMessage message: String)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
message
The message sent by the creative.
-
Notifies the delegate that the banner view stuck/unstuck one of its subview to the view hierarchy.
This method will only be called when the SASBannerView is added to a scrollview instance (UITableView, UICollectionView…) and only for ads format with the stickToTop feature.
Implement this method if you want to be able to modify the frame of the sticked view, for example if your UINavigationBar disappears at some point of the scroll, etc…
Note
This method is not only called the first time an ad creative is expanded, but also when the user rotates the device.
Declaration
Objective-C
- (void)bannerView:(nonnull SASBannerView *)bannerView withStickyView:(nonnull UIView *)stickyView didStick:(BOOL)stuck withFrame:(CGRect)stickyFrame;
Swift
optional func bannerView(_ bannerView: SASBannerView, withStickyView stickyView: UIView, didStick stuck: Bool, withFrame stickyFrame: CGRect)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
stickyView
The view instance that is stuck/unstuck to the UIWindow.
stuck
YES if the view is stuck, NO if the view is not stuck anymore
stickyFrame
The frame of the stickyView.
-
Asks the delegate wether the banner view can stick to top or not.
This method will be called when the SASBannerView is binded to a scrollview instance (UITableView, UICollectionView…) and when stick to top conditions are met: ads format with this feature, scroll view offset reaching top of the screen, etc…
Implement this method if you want to be able to prevent an ad from sticking to top: for example, if you have loaded several banner views in the same controller and display only some of them, etc…
Note
This method is not only called the first time stick to top conditions are met but every time until ad is stuck.
Declaration
Objective-C
- (BOOL)bannerViewCanStickToTop:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewCanStickToTop(_ bannerView: SASBannerView) -> Bool
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Tells the banner view 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 ad view’s behavior with AVAudioSession.
Use the adViewWillPlayAudio: and adViewDidFinishPlayingAudio: 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)bannerViewShouldHandleAudioSession:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewShouldHandleAudioSession(_ bannerView: SASBannerView) -> Bool
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
Return Value
YES (default if not implemented) to let ad view handle AVAudioSession for native videos, NO to implement your own behavior.
-
Notifies the delegate that the banner view will start playing native audio.
Implement this method if you want to know when an ad view 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.
Note
This method will only be triggered by native creatives, not by HTML based creatives.
Declaration
Objective-C
- (void)bannerViewWillPlayAudio:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewWillPlayAudio(_ bannerView: SASBannerView)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Notifies the delegate that the banner view finished playing native audio.
Implement this method if you want to know when an ad view finishes playing native audio (e.g. from a native video).
This is useful if you want to resume your own audio, change the shared AudioSession or trigger other custom behavior.
Note
This method will only be triggered by native creatives, not by HTML based creatives.
Declaration
Objective-C
- (void)bannerViewDidFinishPlayingAudio:(nonnull SASBannerView *)bannerView;
Swift
optional func bannerViewDidFinishPlayingAudio(_ bannerView: SASBannerView)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
-
Notifies the delegate that a video event has been generated by the banner view.
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)bannerView:(nonnull SASBannerView *)bannerView didSendVideoEvent:(SASVideoEvent)videoEvent;
Swift
optional func bannerView(_ bannerView: SASBannerView, didSend videoEvent: SASVideoEvent)
Parameters
bannerView
The instance of SASBannerView that called this delegate method.
videoEvent
The video event that has been triggered.