GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

BlazePlayerCustomActionButtonParams iOS

BlazePlayerCustomActionButtonParams

The BlazePlayerCustomActionButtonParams struct contains identifying information and appMetadata
for custom action buttons in the Blaze Players.

This struct helps track and manage custom buttons by providing a unique identifier and
additional contextual information that can be used when handling button interactions.

id

var id: String

A unique identifier for the custom action button.

This identifier can be used to track interactions with the button or to retrieve
the button from a collection of buttons.

name

var name: String

The name of the custom action button.

appMetadata

var appMetadata: [String: AnyHashable]

Additional appMetadata associated with the custom action button.

Use this dictionary to store any relevant information that should be associated with
the button, such as analytics event names, feature flags, or other contextual data
that might be needed when handling button interactions.

sdkMetadata

public private(set) var sdkMetadata: [String: AnyHashable]

Additional metadata managed by the SDK.

  • Note: Do not attempt to modify this property directly. It is managed by the SDK.

Visibility Condition

visibilityCondition - property

public var visibilityCondition: VisibilityCondition?

The visibility condition that determines when this button should be shown.

Example Usage:

// Show button only when playerId exists (using preset method)
visibilityCondition: BlazeExtraInfoKeyPreset.playerId.exists()

// Show button only for specific team (using preset method)
visibilityCondition: BlazeExtraInfoKeyPreset.teamId.equals("team123")

// Show button only for live content (using preset method)
// Note: metadata values are strings, so use "true" for boolean comparison
visibilityCondition: BlazeExtraInfoKeyPreset.isCurrentlyLive.equals("true")

// Show button for specific games or seasons (using preset methods)
visibilityCondition: .or([
    BlazeExtraInfoKeyPreset.gameId.equals("game456"),
    BlazeExtraInfoKeyPreset.seasonId.equals("season2024")
])

// Complex conditions with AND/OR logic (using preset methods)
visibilityCondition: .and([
    BlazeExtraInfoKeyPreset.playerId.exists(),
    .or([
        BlazeExtraInfoKeyPreset.teamId.equals("team123"),
        BlazeExtraInfoKeyPreset.isCurrentlyLive.equals("true")
    ])
])

// Using raw strings for custom keys
visibilityCondition: .and([
    .keyExists("customKey"),
    .keyEquals("anotherCustomKey", "customValue")
])

Enum - VisibilityCondition

CaseAssociated ValuesDescription
alwaysButton is always visible
neverButton is never visible
keyExistskey: StringButton is visible when the specified metadata key exists
keyNotExistskey: StringButton is visible when the specified metadata key does not exist
keyEqualskey: String, value: AnyHashableButton is visible when the metadata key equals the specified value
keyNotEqualskey: String, value: AnyHashableButton is visible when the metadata key does not equal the specified value
keyInkey: String, values: [AnyHashable]Button is visible when the metadata key's value is in the specified array
keyNotInkey: String, values: [AnyHashable]Button is visible when the metadata key's value is not in the specified array
keyGreaterThankey: String, threshold: DoubleButton is visible when the numeric metadata value is greater than the threshold
keyLessThankey: String, threshold: DoubleButton is visible when the numeric metadata value is less than the threshold
keyBetweenkey: String, min: Double, max: DoubleButton is visible when the numeric metadata value is between the specified range (inclusive)
keyContainskey: String, substring: StringButton is visible when the string metadata value contains the specified substring
andconditions: [VisibilityCondition]Button is visible when ALL of the specified conditions are true
orconditions: [VisibilityCondition]Button is visible when ANY of the specified conditions are true
notcondition: VisibilityConditionButton is visible when the specified condition is NOT true

Convenient Preset Methods

exists

public func exists() -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this metadata key exists.

  • Returns: A visibility condition that evaluates to true when the key exists

Example:

// Check if playerId exists
visibilityCondition: BlazeExtraInfoKeyPreset.playerId.exists()

notExists

public func notExists() -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this metadata key does not exist.

  • Returns: A visibility condition that evaluates to true when the key does not exist

Example:

// Check if playerId does not exist
visibilityCondition: BlazeExtraInfoKeyPreset.playerId.notExists()

equals

public func equals(_ value: AnyHashable) -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this metadata key equals a specific value.

  • Parameter value: The value to compare against
  • Returns: A visibility condition that evaluates to true when the key equals the value

Example:

// Check if teamId equals "team123"
visibilityCondition: BlazeExtraInfoKeyPreset.teamId.equals("team123")
     
// Check if isCurrentlyLive equals true (metadata values are strings)
visibilityCondition: BlazeExtraInfoKeyPreset.isCurrentlyLive.equals("true")

notEquals

public func notEquals(_ value: AnyHashable) -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this metadata key does not equal a specific value.

  • Parameter value: The value to compare against
  • Returns: A visibility condition that evaluates to true when the key does not equal the value

Example:

// Check if teamId is not "team123"
visibilityCondition: BlazeExtraInfoKeyPreset.teamId.notEquals("team123")

isIn

public func isIn(_ values: [AnyHashable]) -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this metadata key's value is in a specified array.

  • Parameter values: The array of values to check membership
  • Returns: A visibility condition that evaluates to true when the key's value is in the array

Example:

// Check if playerId is one of specific players
visibilityCondition: BlazeExtraInfoKeyPreset.playerId.isIn(["player1", "player2", "player3"])
     
// Check if teamId is one of specific teams
visibilityCondition: BlazeExtraInfoKeyPreset.teamId.isIn(["team123", "team456"])

isNotIn

public func isNotIn(_ values: [AnyHashable]) -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this metadata key's value is not in a specified array.

  • Parameter values: The array of values to check membership
  • Returns: A visibility condition that evaluates to true when the key's value is not in the array

Example:

// Check if playerId is not one of specific players
visibilityCondition: BlazeExtraInfoKeyPreset.playerId.isNotIn(["bannedPlayer1", "bannedPlayer2"])

greaterThan

public func greaterThan(_ threshold: Double) -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this numeric metadata key's value is greater than a threshold.

  • Parameter threshold: The minimum value (exclusive)
  • Returns: A visibility condition that evaluates to true when the key's value is greater than the threshold

Example:

// Check if some numeric score is greater than 8.0
// Note: metadata "8.5" string will be parsed to 8.5 for comparison
visibilityCondition: .customNumericKey.greaterThan(8.0)

lessThan

public func lessThan(_ threshold: Double) -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this numeric metadata key's value is less than a threshold.

  • Parameter threshold: The maximum value (exclusive)
  • Returns: A visibility condition that evaluates to true when the key's value is less than the threshold

Example:

// Check if some numeric score is less than 5.0
// Note: metadata "4.2" string will be parsed to 4.2 for comparison
visibilityCondition: .customNumericKey.lessThan(5.0)

between

public func between(_ min: Double, _ max: Double) -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this numeric metadata key's value is between two values (inclusive).

  • Parameters:
    • min: The minimum value (inclusive)
    • max: The maximum value (inclusive)
  • Returns: A visibility condition that evaluates to true when the key's value is between min and max

Example:

// Check if some numeric score is between 5.0 and 10.0
// Note: metadata "7.5" string will be parsed to 7.5 for comparison
visibilityCondition: .customNumericKey.between(5.0, 10.0)

contains

public func contains(_ substring: String) -> BlazePlayerCustomActionButtonParams.VisibilityCondition

Creates a condition that checks if this string metadata key's value contains a substring.

  • Parameter substring: The substring to search for
  • Returns: A visibility condition that evaluates to true when the key's value contains the substring

Example:

// Check if activeLabels contains "highlight"
visibilityCondition: BlazeExtraInfoKeyPreset.activeLabels.contains("highlight")


Did this page help you?