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: StringA 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: StringThe 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
| Case | Associated Values | Description |
|---|---|---|
| always | Button is always visible | |
| never | Button is never visible | |
| keyExists | key: String | Button is visible when the specified metadata key exists |
| keyNotExists | key: String | Button is visible when the specified metadata key does not exist |
| keyEquals | key: String, value: AnyHashable | Button is visible when the metadata key equals the specified value |
| keyNotEquals | key: String, value: AnyHashable | Button is visible when the metadata key does not equal the specified value |
| keyIn | key: String, values: [AnyHashable] | Button is visible when the metadata key's value is in the specified array |
| keyNotIn | key: String, values: [AnyHashable] | Button is visible when the metadata key's value is not in the specified array |
| keyGreaterThan | key: String, threshold: Double | Button is visible when the numeric metadata value is greater than the threshold |
| keyLessThan | key: String, threshold: Double | Button is visible when the numeric metadata value is less than the threshold |
| keyBetween | key: String, min: Double, max: Double | Button is visible when the numeric metadata value is between the specified range (inclusive) |
| keyContains | key: String, substring: String | Button is visible when the string metadata value contains the specified substring |
| and | conditions: [VisibilityCondition] | Button is visible when ALL of the specified conditions are true |
| or | conditions: [VisibilityCondition] | Button is visible when ANY of the specified conditions are true |
| not | condition: VisibilityCondition | Button is visible when the specified condition is NOT true |
Convenient Preset Methods
exists
public func exists() -> BlazePlayerCustomActionButtonParams.VisibilityConditionCreates 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.VisibilityConditionCreates 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.VisibilityConditionCreates 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.VisibilityConditionCreates 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.VisibilityConditionCreates 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.VisibilityConditionCreates 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.VisibilityConditionCreates 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.VisibilityConditionCreates 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.VisibilityConditionCreates 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.VisibilityConditionCreates 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")Updated about 2 months ago
