I’m and Android (Kotlin) and iOS (Swift) developer, and I’m trying to start using KMM to unify my codebases. I’ve got a decent grasp of the structure, but I can’t find any documentation on how to run shared code at specific times during the app’s lifecycle (at startup and/or at shutdown). I understand that I can go directly into platform-specific code, and do it there, but I would really prefer to have a unified way of doing it in shared code instead.
For example, I need to initialize some global objects states. On Android, it would normally go into Application.onCreate()
, and on iOS it would be in App.init()
. But I need to be able to access those global states from shared code, so I need to have them initialized from shared code instead.
How can that be done?