Step 3: Initializing and Loading the SDK
  • 20 Jun 2023
  • 1 Minute to read
  • Dark
    Light

Step 3: Initializing and Loading the SDK

  • Dark
    Light

Article summary

Initializing and Loading the SDK

To initialize the SDK, create a ULConfiguration object. This will store basic settings, the apikey, and the UP-code which will be given to each partner by an UpLift Representitive.

Once created,set it to the ULUpliftSDK. It is highly recommended to not hardcode the UP-code and API key in the source code, instead store them securely. E.g.: in a .properties file that is not pushed to a git repository.

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 ending in -95 and one for production, ending in -5. Please perform all development on the -95 up-code and only use the -5 up-code for production.

/**
 * You can find a Kotlin example in the example project's SplashActivity.kt file
 */
val apikey = "your api key goes here"
val upCode = "UP-xxxxxx-xx";
val checkoutConfiguration = ULCheckoutConfiguration(
    showCloseButton = true,
    screenTimeOut = 30L
)
val configuration = ULConfiguration(
    upCode = upCode,
    apiKey = apikey,
    checkoutConfiguration = checkoutConfiguration,
    apiTimeout = 30L
)
ULUpliftSDK.setConfiguration(context, configuration, object : ConfigurationCallback {
    override fun onSuccess() {
      // This method will be triggered when the initialize method succeeded
    }
    override fun onError(error: ULError) {
      // This method will be triggered when the initialize method failed 
    }
}) 

After successfully configuring the SDK, you must set a ULLocale object to the current configuration. This object defines the language and currency used in the SDK. Please note that you can only use locales that are available for your UP-code. Once you have successfully configured the SDK, you can check the list of available locales and currencies using your configuration.

/**
 * You can find a Android example in the example project's SplashActivity.kt file
 */
val locale = Locale.US
val currency = ULCurrency.ULCurrencyUSD  
val loc = ULLocale(
    locale = Locale.US,
    ulCurrency = ULCurrency.ULCurrencyUSD
)
val error = ULUpliftSDK.getConfiguration().selectLocale(loc)
if (error != null) {
    //Success locale setting
} else {
    //Error at locale setting
}

Was this article helpful?