5. Initializing the SDK and AdsManager
5.1 Application class
Extend AppsKitSDKApplication and implement its five abstract members:
class YourApplication : AppsKitSDKApplication() {
// Encrypted default-config JSON to fall back on before Remote Config is fetched.
// Provided to you from the AKS portal for your app.
override fun setAKSDefaultConfigs(): String = "<encrypted-config-json-from-aks-portal>"
override fun isTestMode(): Boolean = BuildConfig.DEBUG
override fun isDevMode(): Boolean = BuildConfig.DEBUG
override fun setPlatform(): Platform = Platform.GOOGLE // or Platform.AMAZON
override fun onConfigsReadyToUse(remoteConfig: FirebaseRemoteConfig) {
// Called once Firebase Remote Config has been fetched/activated.
// Optional hook if you need to read custom remote-config keys yourself.
}
}onCreate() in the base class already does the heavy lifting for you — it calls AppsKitSDK.initialize/setPlatform/setTestMode/setDevMode, fetches and saves the default config, kicks off manageRemoteConfigs(), and calls AppsKitSDK.initMMP() to wire up AppsFlyer/Adjust/Solar Engine. You don't need to call any of that yourself.
5.2 Initializing without extending AppsKitSDKApplication
Extending AppsKitSDKApplication isn't mandatory — it's a convenience wrapper. If your app already has its own Application base class you can't give up, you can call the same AppsKitSDK methods it calls internally, directly from your own Application.onCreate():
class YourApplication : Application() {
override fun onCreate() {
super.onCreate()
FirebaseApp.initializeApp(this)
AppsKitSDK.initialize(PlatformContext(this), this)
AppsKitSDK.setPlatform(Platform.GOOGLE) // or Platform.AMAZON
AppsKitSDK.setTestMode(BuildConfig.DEBUG)
AppsKitSDK.setDevMode(BuildConfig.DEBUG)
AppsKitSDK.setTimeToFetchRemoteConfigInSeconds(3600) // optional, defaults to 3600
AppsKitSDK.saveDefaultConfigJson("<encrypted-config-json-from-aks-portal>")
AppsKitSDK.manageRemoteConfigs(object : OnRemoteConfigAvailable {
override fun onRemoteConfigReadyToFetch(remoteConfig: FirebaseRemoteConfig) {
// optional — your own hook into the fetched remote config
}
})
AppsKitSDK.initMMP() // wires up AppsFlyer / Adjust / Solar Engine from remote-config keys
// AppsKitSDKApplication does this for you via ActivityLifecycleCallbacks. Without it,
// AppsKitSDK has no "current activity" — native-ad preloading and any code that calls
// AppsKitSDK.getCurrentActivity() won't have a target to work with.
registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
override fun onActivityResumed(activity: Activity) {
AppsKitSDK.setCurrentActivity(PlatformActivity(activity))
Adjust.onResume() // keeps Adjust session tracking accurate
}
override fun onActivityPaused(activity: Activity) {
Adjust.onPause()
}
override fun onActivityCreated(activity: Activity, bundle: Bundle?) {}
override fun onActivityStarted(activity: Activity) {}
override fun onActivityStopped(activity: Activity) {}
override fun onActivitySaveInstanceState(activity: Activity, bundle: Bundle) {}
override fun onActivityDestroyed(activity: Activity) {}
})
}
}What you give up by not extending the base class: the internet-connectivity broadcast/dialog handling, and the built-in "App Open ad at application level" flow (requestSplashAppOpenAd/showAppOpenAd, triggered automatically from onStart) — those are instance methods of AppsKitSDKApplication itself, not exposed on the AppsKitSDK object. If you still want an App Open ad on cold start, call AdsManager.loadAppOpen/AdsManager.showAppOpen yourself (see §6) at the point in your own startup flow where you want it.
5.3 Activities
Extend AppsKitSDKBaseActivity (for AppCompatActivity-based screens) or AppsKitSDKBaseComponentActivity (for plain ComponentActivity/Compose-only screens):
class HomeActivity : AppsKitSDKBaseActivity() {
override fun setScreenNameAndId(): Pair<Int, String> = Pair(1, "Home")
override fun enableAppAutoUpdate(): Boolean = true
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) // required — this drives ad-network init, preloading,
// session/day tracking, and the auto SCREEN event
setContent { /* your Compose UI */ }
}
}Extending these base classes automatically gives you: ad-network initialization and preloading on first screen, IronSource lifecycle forwarding in onResume/onPause, session/day-count tracking, an internet-connectivity dialog, optional in-app-update prompts, and sendAKSEvent(...) for firing events tied to this screen (see §7). (Adjust's own onResume/onPause forwarding happens at the Application level — see §5.2 — not here.)
Internet connectivity dialog
Both base Activities observe connectivity in onResume() and, by default, show a blocking "no internet" dialog whenever the connection drops, dismissing it automatically on reconnect. This is on for every screen unless you turn it off:
class HomeActivity : AppsKitSDKBaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
showInternetConnectivity(false) // opt this screen out of the automatic dialog
}
// Called on every connectivity change, dialog or not — hook your own UI here
override fun onInternetConnectivityChange(isInternetAvailable: Boolean?) {
// e.g. show/hide your own offline banner
}
// Optional — return an anchor view to get a "back online" Snackbar when the
// dialog dismisses on reconnect. Returns null (no Snackbar) by default.
override fun getSnackBarView(): View? = findViewById(R.id.rootLayout)
}When you call
showInternetConnectivity(false), AKS still callsonInternetConnectivityChange, but it always passestrueregardless of the actual connection state — it doesn't track real connectivity once you've opted out of managing it. Drive your own offline UI off your own connectivity check if you need accurate state here.
Portrait-only restriction
To lock a screen to portrait, call restrictPortraitOnly() (protected, available on both base Activities):
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
restrictPortraitOnly()
}This calls setRequestedOrientation(SCREEN_ORIENTATION_PORTRAIT) on your behalf — except on Android 8.0 (API 26), where it's skipped on purpose, since setRequestedOrientation is known to crash on translucent/floating-themed activities on that specific OS version.
5.4 Consent and ad initialization
Once you've collected consent (e.g. via Google's UMP/CMP flow), tell AKS so it knows ads are allowed to show:
AdsManager.initializeAds(userHasGivenConsent = true, isCCPAConsent = true)5.5 Remove Ads / IAP gating
If your app sells a "remove ads" purchase, wire it through AKS rather than gating ad calls yourself — every load/show call already checks this flag internally:
AppsKitSDK.setRemoveAdsStatus(true) // call after a successful purchase/restore
AppsKitSDK.getRemoveAdsStatus() // check current status