Hi
Can you please share how to close an app on iOS?
On Android we can do something like:
Copy code
fun Context.findActivity(): ComponentActivity? = when (this) {
is ComponentActivity -> this
is ContextWrapper -> baseContext.findActivity()
else -> null
}
LocalContext.current.findActivity()?.finish()
but what about iOS?
Thanks in advance
f
François
12/03/2024, 2:12 PM
No official way to close an app on iOS.
But you can still use Exit or some alternative, but it’s not clean close, it’s like crashing the app.
👍 1
j
Jason
12/05/2024, 12:04 AM
You showed closing an Android Activity in your snippet, the same thing on iOS would be closing a ViewController by using
dismiss
or
popViewController
API depending on if your showing View from a nav controller or a standalone view controller.
f
François
12/05/2024, 10:07 AM
@Jason you can’t close properly by code an iOS application, it’s by design