VastMacroConfig

@objc(BMPVastMacroConfig)
@objcMembers
public class VastMacroConfig : NSObject, @unchecked Sendable

Contains configuration options for VAST macros.

  • Type alias for VAST macro value provider. The returned values are used to replace the VAST macros in the ad tag and tracking URLs. Returned values will be URL encoded before replacing the VAST macro.

    Note

    macro.name is case sensitive. To handle case insensitivity, convert the name to lowercase before comparing.

    Returning empty array results in keeping the VAST macro unchanged.

    It is good practice to not replace unknown macros and return macro.values as a fallback. For more details consult the VAST standard (version 4.3, section 6.1).

    Example:

     vastMacroConfig.valueProvider = { macro, context in
         switch macro.name {
         case "CUSTOMMACRO":
             // return static values
             return ["custom value"]
         case "PLAYERMACRO":
             // return the provided values unchanged
             return macro.values
         case "CONTEXTAWARE":
             // return values based on the context
             return context.kind == .tracking ? ["value for tracking"] : ["value for ad tag"]
         case "OVERRIDEPLAYERMACRO":
             // return values overriding the provided value
             return ["overridden value"]
         case "COMBINEDMACRO":
             // return combined values of the provided values and custom values
             return macro.values + ["overridden value"]
         default:
             // return the provided values unchanged for any unhandled macros
             return macro.values
         }
     }
    

    Declaration

    Swift

    public typealias VastMacroValueProvider = (_ macro: VastMacro, _ context: VastMacroContext) -> [String]

    Parameters

    macro

    The VAST macro to resolve. See VastMacro for details.

    context

    The context to resolve the VAST macro in.

    Return Value

    The resolved values for the VAST macro.

  • Value provider for VAST macros.

    The returned values are used to replace the VAST macros in the ad tag and tracking URLs. See VastMacroValueProvider for details.

    Note

    The value provider is called for each VAST macro in the ad tag and tracking URLs.

    Declaration

    Swift

    public var valueProvider: VastMacroValueProvider?