Skip to content

Video Advertising Integration Guide

WARNING

If you are unsure about the integration steps, please reach out to your publisher manager for assistance.

This guide provides instructions on how to integrate video advertising using the RingierAd SDK.

Available Functions

These are the current and recommended functions for video advertising.

getVMAPVAST(...)

This function returns a VMAP (Video Multiple Ad Playlist) VAST video URL. VMAP is used to schedule multiple ads within a video content stream, such as pre-rolls, mid-rolls, and post-rolls.

Function Signature:

swift
public static func getVMAPVAST(
    channel: String,
    formats: [String],
    pageType: String? = nil,
    adbreaks: String,
    vtype: String,
    keywords: Keywords = [:],
    duration: Int? = nil,
    urlString: String? = nil
) -> URL?

Parameters:

  • channel: The channel or category (e.g., "News", "Sport", "Home").
  • formats: An array of format strings (e.g., "PREROLL_1", "MIDROLL_1") or aliases.
  • pageType: (Optional) The page type to resolve an alias if multiple placements exist for it.
  • adbreaks: A string defining the ad breaks (e.g., "0,15,30").
  • vtype: A string specifying the video type.
  • keywords: (Optional) A dictionary of additional keywords for targeting.
  • duration: (Optional) The duration of the video in seconds.
  • urlString: (Optional) The URL of the current page.

Returns:

An optional URL for the VMAP VAST ad. Returns nil if the configuration is not available.

Example Usage:

swift
let adUrl = RingierAd.getVMAPVAST(
    channel: "Sport",
    formats: ["PREROLL_1", "MIDROLL_1"],
    adbreaks: "0,60,120",
    vtype: "shortform",
    keywords: ["tag": ["football"]],
    duration: 300,
    urlString: "https://example.com/sport/article-id1278.html"
)

if let url = adUrl {
    // Use the URL with your video player
    print("VMAP URL: \(url)")
}

getNormalVAST(...)

This function returns a standard VAST (Video Ad Serving Template) URL. VAST is used for single ad insertion in video content.

Function Signature:

swift
public static func getNormalVAST(
    channel: String,
    placementOrAlias: String,
    pageType: String? = nil,
    keywords: Keywords = [:],
    duration: Int? = nil,
    urlString: String? = nil
) -> URL?

Parameters:

  • channel: The channel or category (e.g., "News", "Sport", "Home").
  • placementOrAlias: The placement name or alias identifier.
  • pageType: (Optional) The page type to resolve an alias if multiple placements exist for it.
  • keywords: (Optional) A dictionary of additional keywords for targeting.
  • duration: (Optional) The duration of the video in seconds.
  • urlString: (Optional) The URL of the current page.

Returns:

An optional URL for the VAST ad. Returns nil if the configuration is not available.

Example Usage:

swift
let adUrl = RingierAd.getNormalVAST(
    channel: "Sport",
    placementOrAlias: "VIDEO_PREROLL",
    keywords: ["tag": ["football"]],
    duration: 300,
    urlString: "https://example.com/sport/article-id1278.html"
)

if let url = adUrl {
    // Use the URL with your video player
    print("VAST URL: \(url)")
}

Deprecated Functions

The following functions are deprecated and should not be used in new integrations. They will be removed in a future release.

getSSAIVASTJson(...)

Deprecated: This function was used to get a JSON dictionary for SSAI (Server-Side Ad Insertion) VAST.

swift
@available(*, deprecated, message: "This function will be deprecated in the next release.")
public static func getSSAIVASTJson(
    channel: String,
    placementOrAlias: String,
    pageType: String? = nil,
    keywords: Keywords = [:],
    duration: Int? = nil,
    urlString: String? = nil
) -> [String: Any]?

getSSAIVAST(...)

Deprecated: This function was used to get an SSAI (Server-Side Ad Insertion) VAST video URL.

swift
@available(*, deprecated, message: "This function will be deprecated in the next release.")
public static func getSSAIVAST(
    channel: String,
    placementOrAlias: String,
    pageType: String? = nil,
keywords: Keywords = [:],
    duration: Int? = nil,
    urlString: String? = nil
) -> URL?

getGoogleDAIJson(...)

Deprecated: This function was used to get a video JSON for Google DAI (Dynamic Ad Insertion).

swift
@available(*, deprecated, message: "This function will be deprecated in the next release.")
public static func getGoogleDAIJson(
    channel: String,
    placementOrAlias: String,
    pageType: String? = nil,
    keywords: Keywords = [:],
    urlString: String? = nil
) -> [String: Any]?