SDK Documentation: Cloud Config
-
Once you have set up the SDK, we will load your latest configuration settings for the current app version at startup, then you can read them however you want in your app.
Swift:
func application(application: ..., didFinishLaunchingWithOptions: ...) { ATKConfigReady({ ThumbnailUploadService.setImageWidth(ATKConfigInteger("imageWidth", 2048), andHeight:ATKConfigInteger("imageHeight", 2048)) }) }
-
Add Variables to Your Code
Use config settings in your code, just like you might use application-wide constants.
func onTapButton(sender: UIButton) { let overlayTitle = ATKConfigString("promoOverlayTitle", "Upgrade") let alert = UIAlertController(title: overlayTitle, message: "...", preferredStyle: .Alert) ... }
The SDK provides typed wrapper functions for fetching config variables. They require a second parameter, a default, in order to ensure your code will work in conditions where there is no network access.
-
How It Works
The latest configuration values are loaded at application startup and periodically while the app is in the foreground. If you’d like to ensure variables are available before using them, you can use our handy ready wrapper:
func application(application: ..., didFinishLaunchingWithOptions: ...) { AppToolkit.launchWithToken("...") ATKConfigReady({ ThumbnailUploadService.setImageWidth(ATKConfigInteger("imageWidth", 2048), andHeight:ATKConfigInteger("imageHeight", 2048)) }) }
We have the following typed wrapper functions:
ATKConfigInteger()
,ATKConfigDouble()
,ATKConfigBool()
, andATKConfigString()
.If you access the
ATKConfigXXX()
functions before the configuration has been fetched from our server, the SDK will return the most recently fetched value from a previous response, or the default if we have not been able to talk to the SDK at all yet.