- 16 Jun 2025
- 1 Minute to read
- DarkLight
Step 2: Initializing and Loading the SDK
- Updated on 16 Jun 2025
- 1 Minute to read
- DarkLight
Initializing and Loading the SDK
Uplift manages all partner configuration and offerings through unique partner IDs that are called up-codes. Partners are provided two up-codes, one for development and one for production.
Initialization of the SDK usually takes place in your UIApplicationDelegate
's didFinishLaunchingWithOptions:
method. Use your up-codes and API key to create ULConfiguration
. It is generally advisable to use a compile-time attribute to switch between your up-codes.
let apikey = "your api key goes here"
#if DEBUG
let upCode = "UP-xxxxxx-xxx-95"
#else
let upCode = "UP-xxxxxx-xxx-5"
#endif
let configuration = ULConfiguration(apiKey: apiKey,
upCode: upCode,
controllerTitle: "Controller Title")
The controllerTitle
property allows to modify the title of the controller provided by the SDK. Its default value is: Flexpay
.
There are other properties available within the configuration that may need to be set for your app. Set them here, as necessary.
// Basic settings
configuration.checkoutConfiguration.useScrollableContent = true
Once all necessary configuration values are set, pass the configuration object to ULUpLiftSDK.shared
. This can be done using a callback or using Swift's async syntax. NOTE: if using the async syntax in the -didFinishLaunchingWithOptions:
method, the action must be enclosed in a Task
.
Using a Callback
// Using a callback
ULUpLiftSDK.shared.setConfiguration(configuration) { result in
switch result {
case .success(_):
print("Success configuration, set the locale")
case .failure(let error):
print("Error at configuration: \(error)")
}
}
Using Async
Task {
try await ULUpLiftSDK.shared.setConfigurationAsync(configuration)
}
Setting the Locale
When the configuration is successful, you have to set an ULLocale
object to the SDK's current configuration. It defines the language and the currency used in the SDK. You can only use locales which are available for your up-code.
After a success configuration, you can check the list of available locales and currencies with your configuration.
let locale = Locale(identifier: "en-US")
let currency: ULCurrency = .usd
let ulLocale = ULLocale(locale: locale, currency: currency)
if let error = ULUpLiftSDK.shared.currentConfiguration?.select(locale: ulLocale) {
print("Error at locale setting: \(error)")
} else {
print("Success locale setting")
}
Condensing the Code
Using throwing and async calls together, this process can be simplified significantly.
Task {
do {
try await ULUpLiftSDK.shared.setConfigurationAsync(configuration)
let locale = Locale(identifier: "en-US")
let currency: ULCurrency = .usd
try ULUpLiftSDK.shared.currentConfiguration?.select(locale: ulLocale)
print("Uplift SDK is now initialized.")
} catch {
print("Error initializing Uplift SDK: \(error)")
}
}