VarioqubFacade
public final class VarioqubFacade
extension VarioqubFacade: RuntimeOptionable
extension VarioqubFacade: VarioqubConfigurable
extension VarioqubFacade: VarioqubDefaultsSetupable
extension VarioqubFacade: FlagProvider
An entry point for Varioqub. Use shared
to access Varioqub.
-
A global Varioqub instance.
Declaration
Swift
public static let shared: VarioqubFacade
-
Varioqub initialization. Must be called in the first place.
Declaration
Swift
public func initialize(clientId: String, config: VarioqubConfig = .default, idProvider: VarioqubIdProvider?, reporter: VarioqubReporter?)
Parameters
clientId
A string in the following format: “appmetrica.\(appId)”. You can take the appId from https://appmetrica.yandex.ru/.
config
The Varioqub configuration. After initialization, you can’t change it.
idProvider
Optional, if you want to use AppMetrica identifiers. Currently available only for MetricaAdapter and MetricaAdapterReflection.
reporter
Optional, if you want to use analytics. Currently available only for MetricaAdapter and MetricaAdapterReflection.
-
An additional key-value set to send to Varioqub server.
No operation is performed before
initialize(clientId:config:idProvider:reporter:)
is called.Declaration
Swift
public var clientFeatures: ClientFeatures { get set }
-
Enables or disables sending event when a new config is activated.
You should provide the
initialize(clientId:config:idProvider:reporter:)
reporter and implementsendActivateEvent(_:)
(for example, using AppmetricaAdapter).See also
activateConfigAndWait()
andactivateConfig(_:)
.Declaration
Swift
public var sendEventOnChangeConfig: Bool { get set }
-
Varioqub identifier.
An identifier that allows setting up the experiment for a specific device only. See Varioqub SDK integration documentation for more information. It returns nil before
fetchConfig(_:)
is completed.Declaration
Swift
public var varioqubId: String? { get }
-
Fetches a new config and stores it.
This method doesn’t apply the config, see
activateConfig(_:)
andactivateConfigAndWait()
for that.Declaration
Swift
public func fetchConfig(_ callback: FetchCallback?)
Parameters
callback
Called when fetching is completed.
-
Activates a config and notifies via a callback when it completes.
This method doesn’t block the callee.
See also:
VarioqubFacade/activateConfigAndWait()(_:)
.Declaration
Swift
public func activateConfig(_ callback: ActivateCallback?)
Parameters
callback
called when activating is completed
-
Declaration
Swift
public func activateConfigAndWait()
-
Fetches a new config and activates it.
Activating a new config isn’t performed when fetching it fails. If the fetch status is
ConfigFetcherAnswer.success
,ConfigFetcherAnswer.throttled
, orConfigFetcherAnswer.cached
, it activates a new config.Declaration
Swift
public func fetchAndActivateConfig(_ callback: FetchCallback?)
Parameters
callback
Notifies when fetching and activating is finished.
-
Adds key-value pairs into the config.
The server config has higher priority over these values.
Method doesn’t block callee and notifies about finishing via callback.
See also:
setDefaultsAndWait(_:)
.Declaration
Swift
public func setDefaults(_ defaults: [VarioqubFlag : String], callback: DefaultsCallback?)
Parameters
defaults
The dictionary with flags and values.
callback
Notifies when setting is completed.
-
Loads key-value pairs from an XML.
See details about loading and format: https://yandex.ru/support2/varioqub-app/en/sdk/ios/integration#step-3-set-the-default-configuration-using-an-xml-file
See also:
loadXmlAndWait(at:)
.Declaration
Swift
public func loadXml(at path: URL, callback: XmlParserCallback?)
Parameters
path
The path to the XML file.
callback
Notifies about finishing.
-
Loads key-value pairs from XML-encoded data.
See details about loading and format: https://yandex.ru/support2/varioqub-app/en/sdk/ios/integration#step-3-set-the-default-configuration-using-an-xml-file
See also:
loadXmlAndWait(from:)
.Declaration
Swift
public func loadXml(from data: Data, callback: XmlParserCallback?)
Parameters
data
The data that represents XML.
callback
Notifies about finishing.
-
Adds key-value pairs into config.
The server config has higher priority over these values.
See also:
setDefaults(_:callback:)
.Declaration
Swift
public func setDefaultsAndWait(_ defaults: [VarioqubFlag : String])
Parameters
defaults
The dictionary with flags and values.
-
Loads key-value pairs from an XML.
See details about loading and format: https://yandex.ru/support2/varioqub-app/en/sdk/ios/integration#step-3-set-the-default-configuration-using-an-xml-file
See also:
VarioqubFacade/loadXmlAndWait(at:)
.Declaration
Swift
public func loadXmlAndWait(at path: URL) throws
Parameters
path
The path to the XML file.
-
Loads key-value pairs from XML-encoded data.
See details about loading and format: https://yandex.ru/support2/varioqub-app/en/sdk/ios/integration#step-3-set-the-default-configuration-using-an-xml-file
See also:
loadXmlAndWait(at:)
.Declaration
Swift
public func loadXmlAndWait(from data: Data) throws
Parameters
from
The data that represents XML.
-
All active flags.
Declaration
Swift
public var allItems: [VarioqubFlag : VarioqubConfigValue] { get }
-
All active keys.
Declaration
Swift
public var allKeys: Set<VarioqubFlag> { get }
-
Gets the value for the flag.
Declaration
Swift
public func get<T>(for flag: VarioqubFlag, type: T.Type, defaultValue: T?) -> T where T : VarioqubInitializableByValue
Parameters
flag
The flag.
type
Returns T.
defaultValue
The value that will be returned if nothing could be found.
Return Value
The value in the active config.
-
Gets the raw value that can be convert to a specific type.
Declaration
Swift
public func getValue(for flag: VarioqubFlag) -> VarioqubConfigValue
Parameters
flag
The flag.
Return Value
The value in the active config or an empty value if nothing could be found.