TealiumInstanceManager
Provides a method of accessing a previously-instantiated instance of Tealium, using the key format “account.profile.environment”.
Class: TealiumInstanceManager
The following summarizes the commonly used methods of the iOS (Swift) TealiumInstanceManager class.
| Method | Description |
|---|---|
getInstanceByName() |
Returns a Tealium instance for a specified account/profile/environment key |
removeInstance() |
Removes a Tealium instance for a specified TealiumConfig instance |
removeInstanceForKey() |
Removes a Tealium instance for a specified key (format: "ACCOUNT.PROFILE.ENVIRONMENT") |
getInstanceByName()
Returns a Tealium instance for a specified key (format: “ACCOUNT.PROFILE.ENVIRONMENT”).
getInstanceByName(instanceKey: String) -> Tealium?
| Parameter | Type | Description | Example |
|---|---|---|---|
instanceKey |
String |
The specified key of the Tealium instance to be retrieved |
"companyXYZ.main.dev" |
The following example shows how to get a Tealium instance for a specified account/profile/environment key:
let instanceManager = TealiumInstanceManager.shared
let myTealiumInstance = instanceManager.getInstanceByName("ACCOUNT.PROFILE.ENVIRONMENT")
// call any methods on the Tealium instance you just retrieved
// myTealiumInstance?.track("myevent")
removeInstance()
Removes (deallocates) a Tealium instance for a specified TealiumConfig instance. If neither this method nor the removeInstanceForKey() method is called, then a permanent reference is held and the instance is not removed.
removeInstance(config)
| Parameter | Type | Description | Example |
|---|---|---|---|
config |
TealiumConfig |
The Tealium configuration instance to be removed | myTealiumConfig |
The following example removes a Tealium instance for a specified account/profile/environment key:
instanceManager.removeInstance(myTealiumConfig)
removeInstanceForKey()
Removes (deallocates) a Tealium instance for a specified key (format: “ACCOUNT.PROFILE.ENVIRONMENT”). If neither this method nor the removeInstance() method is called, then a permanent reference is held and the instance is not removed.
removeInstanceForKey(instanceKey)
| Parameter | Type | Description | Example |
|---|---|---|---|
instanceKey |
String |
The specified key of the Tealium instance to be removed |
"companyXYZ.main.dev" |
The following example removes a Tealium instance for a specified account/profile/environment key:
let instanceManager = TealiumInstanceManager.shared
instanceManager.removeInstanceForKey("ACCOUNT.PROFILE.ENVIRONMENT")
tealiumInstances variable
Stores a dictionary of all registered Tealium instances.
The following example shows how to use the variable to retrieve all registered Tealium instances:
let instanceManager = TealiumInstanceManager.shared
let allTealiumInstances = instanceManager.tealiumInstances
// do any required processing with the dictionary of valid Tealium instances
This page was last updated: January 7, 2023