Skip to main content

API Reference

This section provides a complete reference for all publicly available methods within the Experience SDK.

Qualtrics​

The Qualtrics enum serves as the entry point for the SDK. All methods are static and can be invoked directly on the enum.

Swift: Add import QualtricsExperience at the top of any .swift file where you call the SDK.

Methods​

initialize(sdkKey:configuration:)​

Manually initializes the SDK.

Use this method only if you disabled automatic initialization. If SdkKey is present in the Qualtrics dictionary in Info.plist, automatic initialization takes precedence and all manual initialization calls are ignored.

You must call the initialize method before any other SDK method. Calling any other method first will cause errors and undefined behavior.

This method attempts to retrieve the current UIWindow automatically. If it cannot be retrieved, you must provide it explicitly using initialize(sdkKey:window:configuration:).

Parameters​

ParameterTypeDescription
sdkKeyStringThe key used to initialize the SDK. Can be obtained from the App Insights project settings.
configuration (optional)QualtricsConfiguration?Optional configuration object for the SDK. If not provided, uses default settings.

initialize(sdkKey:window:configuration:)​

Manually initializes the SDK.

Use this method only if you disabled automatic initialization. If SdkKey is present in the Qualtrics dictionary in Info.plist, automatic initialization takes precedence and all manual initialization calls are ignored.

You must call the initialize method before any other SDK method. Calling any other method first will cause errors and undefined behavior.

Parameters​

ParameterTypeDescription
sdkKeyStringThe key used to initialize the SDK. Can be obtained from the App Insights project settings.
windowUIWindowThe UIWindow instance.
configuration (optional)QualtricsConfiguration?Optional configuration object for the SDK. If not provided, uses default settings.

setStringProperty(key:value:)​

Sets a custom string property. If a property with the same key already exists, it will be overwritten.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.
valueStringThe string value to set.

setBoolProperty(key:value:)​

Sets a custom bool property. If a property with the same key already exists, it will be overwritten.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.
valueBoolThe bool value to set.

setNumberProperty(key:value:)​

Sets a custom number property. If a property with the same key already exists, it will be overwritten.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.
valueDoubleThe number value to set.

setDateProperty(key:value:)​

Sets a custom date property. If a property with the same key already exists, it will be overwritten.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.
valueDateThe date value to set.

setLanguage(languageCode:)​

Sets a language for incoming intercepts. If language code is applied via this function, autodetected language will be overwritten.

Parameters​

ParameterTypeDescription
languageCodeStringThe language code.

getStringProperty(key:)​

Retrieves a custom string property.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.

Returns​

The String value if found, otherwise nil.

getBoolProperty(key:)​

Retrieves a custom bool property.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.

Returns​

The Bool value if found, otherwise nil.

getNumberProperty(key:)​

Retrieves a custom number property.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.

Returns​

The Double value if found, otherwise nil.

getDateProperty(key:)​

Retrieves a custom date property.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.

Returns​

The Date value if found, otherwise nil.

removeProperty(key:)​

Removes a custom property.

Each custom property must be configured in the App Insights project before it can be used.

Parameters​

ParameterTypeDescription
keyStringThe property key.

reportEvent(_ name: String)​

Reports a custom event by name.

Parameters​

ParameterTypeDescription
nameStringThe name of the event to report.

reportScreenAppearance(_ screenName:)​

Reports that a screen has appeared.

Parameters​

ParameterTypeDescription
screenNameStringThe name of the screen that appeared.

reportScreenDisappearance(_ screenName:)​

Reports that a screen has disappeared.

Parameters​

ParameterTypeDescription
screenNameStringThe name of the screen that disappeared.

reportScreenAppearance(_ screens:)​

Reports a screen appearance event with detailed screen information. Use this overload when you need to track nested screen hierarchies or specify screen types.

Parameters​

ParameterTypeDescription
screens[QualtricsScreen]The screens that appeared, in hierarchy order (outermost to innermost).

reportScreenDisappearance(_ screens:)​

Reports a screen disappearance event with detailed screen information. Use this overload when you need to track nested screen hierarchies or specify screen types.

Parameters​

ParameterTypeDescription
screens[QualtricsScreen]The screens that disappeared, in hierarchy order (outermost to innermost).

Properties​

logLevel​

Controls the verbosity of logs emitted by the SDK.

ValueDescription
.debugLogs detailed troubleshooting (all internal SDK logs).
.info (default)Logs SDK operations and lifecycle events.
.errorLogs errors only.
.noneSilences all logging.

Types​

QualtricsScreen​

Represents a screen that can be reported to the SDK. Used with reportScreenAppearance(_ screens:) and reportScreenDisappearance(_ screens:) when tracking nested screen hierarchies or specifying screen types.

Parameters​

ParameterTypeDescription
screenNameStringThe name of the screen.
screenTypeStringThe type of the screen. Defaults to "Screen".

Example​

import QualtricsExperience

QualtricsScreen(screenName: "Home") // uses default type "Screen"
QualtricsScreen(screenName: "ProductDetails", screenType: "UIViewController") // custom type