Skip to main content

iOS Audience Service

Functions

syncSegmentDefinitions

public func syncSegmentDefinitions(
onSuccess: @escaping () -> Void,
onError: ((Error) -> Void)? = nil
)

Synchronizes segment definitions with the Orchestrator and updates local storage.

Parameters:

  • onSuccess: () -> Void — Called when synchronization completes successfully.
  • onError: ((Error) -> Void)? — Called when an error occurs during synchronization.

getSegmentDefinitions

public func getSegmentDefinitions(
onSuccess: @escaping ([[SegmentDefinition](#segmentdefinition)]) -> Void,
onError: ((Error) -> Void)? = nil
)

Retrieves all available segment definitions from local storage.

Parameters:

  • onSuccess: ([SegmentDefinition]) -> Void — Called with the list of segment definitions.
  • onError: ((Error) -> Void)? — Called when an error occurs while reading from local storage.

getSegmentDefinition

public func getSegmentDefinition(
name: String,
onSuccess: @escaping (SegmentDefinition?) -> Void,
onError: ((Error) -> Void)? = nil
)

Retrieves a segment definition by its name.

Parameters:

  • name: String — The unique name of the segment definition to retrieve.
  • onSuccess: (SegmentDefinition?) -> Void — Called with the matching segment definition, or nil if not found.
  • onError: ((Error) -> Void)? — Called when an error occurs while reading from local storage.

syncSegmentSubscriptions

public func syncSegmentSubscriptions(
onSuccess: @escaping () -> Void,
onError: ((Error) -> Void)? = nil
)

Synchronizes segment subscriptions.

Parameters:

  • onSuccess: () -> Void — Called when synchronization (and optional fetch) completes successfully.
  • onError: ((Error) -> Void)? — Called when an error occurs during synchronization or fetch.

Classes

SegmentDefinition

public class SegmentDefinition: Codable {
public var id: String
public var name: String
public var text: String
public var condition: Filter
public var description: String?
}

SegmentSubscription

public struct SegmentSubscription: Codable {
public var segmentDefinitionId: String
}

Criteria

public class Criteria: RuleCondition {
public let field: String
public let criteriaOperator: String
public let value: String
}

Filter

public class Filter: RuleCondition {
public let type: String?
public let filters: [Filter]?
public let filter: Filter?
public let criteria: Criteria?
}