In my Kotlin Multiplatform Android/iOS app, I have a dialogue popping up when the user starts the app, asking to confirm acceptance of the conditions of use. If he declines, then the activity should close/minimise.
I use an expect/actual function construct, with
expect fun closeapp()
in the commonMain module.
In the Android app, I use:
actual fun closeapp()
{
System.exit(-1)
}
to implement closing of the activity. But I don't know how to achieve the equivalent in iosMain. Any thoughts?
Using System.exit(-1) in the actual implementation for closing the app on Android is a valid approach. It forcefully terminates the application process. However, note that using System.exit() in Android is generally not recommended unless it's a critical situation.
Here's your updated implementation: