Optional setup
All of the methods below are chainable builder methods on AffiseSettings (attribution/src/main/java/com/affise/attribution/settings/AffiseSettings.kt) and must be called between Affise.settings(...) and .start(context).
Production mode
Section titled “Production mode”setProduction(production: Boolean) (AffiseSettings.kt:35-37) toggles SandBox vs Production. Default is true (AffiseSettings.kt:20).
Affise .settings( affiseAppId = "Your appId", secretKey = "Your SDK secretKey" ) .setProduction(false) //To enable debug methods set Production to false .start(this) // Start Affise SDKCustom domain
Section titled “Custom domain”setDomain(domain: String) (AffiseSettings.kt:44-46) — “Set Affise SDK server [domain]. Trailing slash is irrelevant.”
class App : Application() { override fun onCreate() { super.onCreate()
Affise .settings( affiseAppId = "Your appId", secretKey = "Your SDK secretKey", ) .setDomain("https://YoureCustomDomain/") // Set custom domain .start(this) // Start Affise SDK }}Configuration values
Section titled “Configuration values”setConfigValue(key: AffiseConfig, value: Any) (AffiseSettings.kt:86-88) and setConfigValues(values: Map<AffiseConfig, Any>) (AffiseSettings.kt:93-97) pass key/value configuration entries to modules.
AffiseConfig (attribution/src/main/java/com/affise/attribution/settings/AffiseConfig.kt:1-14) currently defines a single key:
enum class AffiseConfig(val key: String) { FbAppId("fb_app_id");Used by the Meta module:
Affise .settings( affiseAppId = "Your appId", secretKey = "Your SDK secretKey", ) .setConfigValue(AffiseConfig.FbAppId, "Your Facebook App Id") .start(this)Disable modules
Section titled “Disable modules”setDisableModules(disableModules: List<AffiseModules>) (AffiseSettings.kt:99-101) lets you skip loading specific modules at runtime.
Affise .settings( affiseAppId = "Your appId", secretKey = "Your SDK secretKey", ) .setDisableModules(listOf( AffiseModules.Advertising, AffiseModules.Subscription, )) .start(this) // Start Affise SDKSpecialized setters
Section titled “Specialized setters”These methods exist on AffiseSettings for advanced use cases. All are documented as “Only for specific use case” in the source:
setAppToken(appToken: String?)(AffiseSettings.kt:65-67) — set an application token.setPartParamName(partParamName: String?)(AffiseSettings.kt:51-53).setPartParamNameToken(partParamNameToken: String?)(AffiseSettings.kt:58-60).
Initialization callbacks
Section titled “Initialization callbacks”setOnInitSuccess(onInitSuccessHandler: OnInitSuccessHandler)(AffiseSettings.kt:72-74)setOnInitError(onInitErrorHandler: OnInitErrorHandler)(AffiseSettings.kt:79-81)
Callback interfaces:
fun interface OnInitSuccessHandler { fun handle() }(OnInitSuccessHandler.kt:4-6)fun interface OnInitErrorHandler { fun handle(e: Exception) }(OnInitErrorHandler.kt:4-6)
Affise .settings( affiseAppId = "Your appId", secretKey = "Your SDK secretKey", ) .setOnInitSuccess { // Called if library initialization succeeded println("Affise: init success") } .setOnInitError { // Called if library initialization failed println("Affise: init error ${it.localizedMessage}") } .start(this)Affise .settings( "Your appId", "Your SDK secretKey" ) .setOnInitSuccess(() -> { // Called if library initialization succeeded System.out.println("Affise: init success"); }) .setOnInitError(e -> { // Called if library initialization failed System.out.println("Affise: init error " + e.getLocalizedMessage()); }) .start(this);