TealiumInstanceManager

public class TealiumInstanceManager

A class that creates and stores all the created Tealium instances and reuses all of its dependencies when a new instance is created with the same account and profile.

All references to created Tealium instances are kept strong, so an instance stays alive until it is explicitly shut down via Tealium.shutdown() or TealiumInstanceManager.shutdown(_:). Dropping the reference returned by create(config:completion:) does not deallocate the instance.

  • The shared TealiumInstanceManager object.

    Declaration

    Swift

    public static let shared: TealiumInstanceManager
  • Creates a new Tealium instance based on the provided config.

    Typical usage in an app would keep the returned instance alive for as long as the app is alive. However, the instance is retained by the manager regardless, so it will stay alive until it is explicitly shut down via Tealium.shutdown() or shutdown(_:).

    Calling this method with a config whose TealiumConfig.key matches an already created instance returns a new Tealium that shares the same underlying implementation.

    Important

    Hold onto the returned Tealium instance for as long as you need it. Calling this method again with the same account/profile combination is supported, but each duplicate call allocates a small amount of internal state (a subject/subscription pair) that lives until shutdown(). Prefer storing and reusing the original return value instead.

    Declaration

    Swift

    public func create(config: TealiumConfig, completion: ((InitializationResult<Tealium>) -> Void)? = nil) -> Tealium

    Parameters

    config

    The required configuration options for this instance.

    completion

    The callback allows the caller to be notified once the instance is ready, or has failed during initialization alongside the cause of the failure.

    Return Value

    The Tealium instance ready to accept input, although if the initialization fails, any method calls made to this object will also fail.

  • Shuts down the given Tealium instance.

    After calling this method, no further input will be processed and future method calls to the instance will fail with TealiumError.instanceShutdown.

    Declaration

    Swift

    public func shutdown(_ tealium: Tealium)

    Parameters

    tealium

    The Tealium instance to shut down.

  • Shuts down the Tealium instance identified by the given key.

    After calling this method, no further input will be processed and future method calls to the instance will fail with TealiumError.instanceShutdown.

    Declaration

    Swift

    public func shutdown(_ key: String)

    Parameters

    key

    The key that identifies the Tealium instance, as provided by TealiumConfig.key.

  • Retrieves an existing Tealium instance, if one has already been created using its TealiumConfig.key and has not been shut down.

    Declaration

    Swift

    public func get(_ config: TealiumConfig, completion: @escaping (Tealium?) -> Void)

    Parameters

    config

    The config that was used to create the instance.

    completion

    The block to receive the Tealium instance on, if found.

  • Retrieves an existing Tealium instance, if one has already been created using its TealiumConfig.key and has not been shut down.

    Declaration

    Swift

    public func get(_ key: String, completion: @escaping (Tealium?) -> Void)

    Parameters

    key

    The key that identifies the Tealium instance.

    completion

    The block to receive the Tealium instance on, if found.