GoogleInteractiveMediaAds Framework Reference

IMAAdDisplayContainer

@interface IMAAdDisplayContainer : NSObject

The IMAAdDisplayContainer is responsible for managing the ad container view and companion ad slots used for ad playback.

  • View containing the video display and ad related UI. This view must be present in the view hierarchy in order to make ad or stream requests.

    Declaration

    Swift

    var adContainer: UIView { get }

    Objective-C

    @property (readonly, nonatomic) UIView *_Nonnull adContainer;
  • View controller containing the ad container. Used to present ad UI in child view controllers. It must be non-nil in order to make ad or stream requests, and it must be in the view hierarchy before ad playback.

    Declaration

    Swift

    weak var adContainerViewController: UIViewController? { get set }

    Objective-C

    @property (nonatomic, nullable) UIViewController *adContainerViewController;
  • The environment to focus on during an ad break. Nil if there is not currently an ad break.

    Declaration

    Swift

    var focusEnvironment: UIFocusEnvironment? { get }

    Objective-C

    @property (readonly, nonatomic, nullable) id<UIFocusEnvironment> focusEnvironment;
  • List of companion ad slots. Can be nil or empty.

    Declaration

    Swift

    var companionSlots: [IMACompanionAdSlot]? { get }

    Objective-C

    @property (readonly, nonatomic, nullable) NSArray<IMACompanionAdSlot *> *companionSlots;
  • Initializes IMAAdDisplayContainer for rendering the ad and displaying the ad UI without any companion slots.

    Declaration

    Swift

    init(adContainer: UIView, viewController adContainerViewController: UIViewController?)

    Objective-C

    - (nonnull instancetype)initWithAdContainer:(nonnull UIView *)adContainer
                                 viewController:(nullable UIViewController *)
                                                    adContainerViewController;

    Parameters

    adContainer

    The view where the ad will be rendered. Fills the view’s bounds.

    adContainerViewController

    The view controller containing the ad container. If not provided here, must be set on the property before making an ads or stream request.

    Return Value

    A new IMAAdDisplayContainer instance

  • Initializes IMAAdDisplayContainer for rendering the ad and displaying the ad UI.

    Declaration

    Swift

    init(adContainer: UIView, viewController adContainerViewController: UIViewController?, companionSlots: [IMACompanionAdSlot]?)

    Objective-C

    - (nonnull instancetype)
        initWithAdContainer:(nonnull UIView *)adContainer
             viewController:(nullable UIViewController *)adContainerViewController
             companionSlots:
                 (nullable NSArray<IMACompanionAdSlot *> *)companionSlots;

    Parameters

    adContainer

    The view where the ad will be rendered. Fills the view’s bounds.

    adContainerViewController

    The view controller containing the ad container. If not provided here, must be set on the property before making an ads or stream request.

    companionSlots

    The array of IMACompanionAdSlots. Can be nil or empty.

    Return Value

    A new IMAAdDisplayContainer instance

  • Registers a view that overlays or obstructs this container as “friendly” for viewability measurement purposes.

    See Open Measurement in the IMA SDK for guidance on what is and what is not allowed to be registered.

    Declaration

    Swift

    func register(_ friendlyObstruction: IMAFriendlyObstruction)

    Objective-C

    - (void)registerFriendlyObstruction:
        (nonnull IMAFriendlyObstruction *)friendlyObstruction;

    Parameters

    friendlyObstruction

    An obstruction to be marked as “friendly” until unregistered.

  • Unregisters all previously registered friendly obstructions.

    Declaration

    Swift

    func unregisterAllFriendlyObstructions()

    Objective-C

    - (void)unregisterAllFriendlyObstructions;