PreferenceCenterState

public class PreferenceCenterState : ObservableObject

Preference Center State

  • The config

    Declaration

    Swift

    public let config: PreferenceCenterConfig
  • Default constructor.

    Declaration

    Swift

    public convenience init(
        config: PreferenceCenterConfig,
        contactSubscriptions: [String: Set<ChannelScope>] = [:],
        channelSubscriptions: Set<String> = Set()
    )

    Parameters

    config

    The preference config

    contactSubscriptions

    The relavent contact subscriptions

    channelSubscriptions

    The relavent channel subscriptions.

  • Checks if the channel is subscribed to the preference state

    Declaration

    Swift

    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

    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

    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

    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

    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