AdUnit

@objcMembers
public class AdUnit : NSObject, DispatcherDelegate

Base class for ad units built for original type of integration.

  • ORTB: imp[].ext.data.pbadslot

    Declaration

    Swift

    public var pbAdSlot: String? { get set }
  • The position of the ad on the screen.

    Declaration

    Swift

    public var adPosition: AdPosition { get set }
  • Initializes a new AdUnit instance with the specified configuration ID, size, and ad formats.

    Declaration

    Swift

    public init(configId: String, size: CGSize?, adFormats: Set<AdFormat>)

    Parameters

    configId

    The configuration ID for the ad unit.

    size

    The primary size of the ad. If nil, a default size of .zero is used.

    adFormats

    A set of ad formats supported by the ad unit.

  • Makes bid request and provides the result as a BidInfo object.

    Declaration

    Swift

    dynamic public func fetchDemand(completionBidInfo: @escaping (_ bidInfo: BidInfo) -> Void)

    Parameters

    completionBidInfo

    A closure called with a BidInfo object representing the fetched demand.

  • Makes bid request for a specific ad object and provides the result code. Setups targeting keywords into the adObject.

    Declaration

    Swift

    dynamic public func fetchDemand(
        adObject: AnyObject,
        completion: @escaping(_ result: ResultCode) -> Void
    )

    Parameters

    adObject

    The ad object for which demand is being fetched.

    completion

    A closure called with the result code indicating the outcome of the demand fetch.

GPID

  • Sets the GPID for the ad unit.

    Declaration

    Swift

    public func setGPID(_ gpid: String?)

    Parameters

    gpid

    The GPID string to set. Can be nil to clear the GPID.

  • Retrieves the current GPID for the ad unit.

    Declaration

    Swift

    public func getGPID() -> String?

    Return Value

    The GPID string, or nil if no GPID is set.

Arbitrary ORTB Configuration

  • Sets the impression-level OpenRTB configuration string for the ad unit.

    Declaration

    Swift

    public func setImpORTBConfig(_ ortbConfig: String?)

    Parameters

    ortbObject

    The impression-level OpenRTB configuration string to set. Can be nil to clear the configuration.

  • Returns the impression-level OpenRTB configuration string.

    Declaration

    Swift

    public func getImpORTBConfig() -> String?

Others

  • This method allows to set the auto refresh period for the demand

    Declaration

    Swift

    public func setAutoRefreshMillis(time: Double)

    Parameters

    time

    refresh time interval

  • This method stops the auto refresh of demand

    Declaration

    Swift

    public func stopAutoRefresh()
  • This method resumes the auto refresh of demand

    Declaration

    Swift

    public func resumeAutoRefresh()