PreferenceCenterState

@MainActor
public class PreferenceCenterState : ObservableObject

Preference Center State

  • The config

    Declaration

    Swift

    @MainActor
    public let config: PreferenceCenterConfig
  • Default constructor.

    Declaration

    Swift

    @MainActor
    public convenience init(
        config: PreferenceCenterConfig,
        contactSubscriptions: [String: Set<ChannelScope>] = [:],
        channelSubscriptions: Set<String> = Set(),
        channelsList: [ContactChannel] = [],
        channelUpdates: AsyncStream<ContactChannelsResult>? = nil
    )

    Parameters

    config

    The preference config

    contactSubscriptions

    The relevant contact subscriptions

    channelSubscriptions

    The relevant channel subscriptions.

    channelsLists

    The relevant channels list.

  • Checks if the channel is subscribed to the preference state

    Declaration

    Swift

    @MainActor
    public func isChannelSubscribed(_ listID: String) -> Bool

    Parameters

    listID

    The preference list ID

    Return Value

    true if any of the channel is subscribed, otherwise false.

  • Checks if the contact is subscribed to the preference state

    Declaration

    Swift

    @MainActor
    public func isContactSubscribed(_ listID: String, scope: ChannelScope)
    -> Bool

    Parameters

    listID

    The preference list ID

    scope

    The channel scope

    Return Value

    true if any the contact is subscribed for that scope, otherwise false.

  • Checks if the contact is subscribed to the preference state

    Declaration

    Swift

    @MainActor
    public func isContactSubscribed(_ listID: String, scopes: [ChannelScope])
    -> Bool

    Parameters

    listID

    The preference list ID

    scopes

    The channel scopes

    Return Value

    true if the contact is subscribed to any of the scopes, otherwise false.

  • Creates a channel subscription binding for the list ID.

    Declaration

    Swift

    @MainActor
    public func makeBinding(channelListID: String) -> Binding<Bool>

    Parameters

    channelListID

    The subscription list ID

    Return Value

    A subscription binding

  • Creates a contact subscription binding for the list ID and scopes.

    Declaration

    Swift

    @MainActor
    public func makeBinding(
        contactListID: String,
        scopes: [ChannelScope]
    ) -> Binding<Bool>

    Parameters

    contactListID

    The subscription list ID

    scopes

    The subscription list scopes

    Return Value

    A subscription binding