Can anyone assist me with this question, <How to d...
# multiplatform
r
Can anyone assist me with this question, How to detect Lifecycle of iOS app in Compose Multiplatform ?
b
What was wrong with the answer provided? 1.6.10 is out of beta release now so this is the direction this will be going in compose multiplatform.
Copy code
val lifecycleOwner = LocalLifecycleOwner.current

lifecycleOwner.lifecycle.addObserver(object : LifecycleEventObserver {
    override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
       
    }
})
r
@Ben Abramovitch The methods viewDidLoad, viewWillAppear, and viewDidAppear are invoked once during the lifecycle of ViewController. However, the methods viewDidDisappear, viewWillDisappear are not being called
b
Okay, but have you tried using the new lifecycle API and read the documentation on how things are mapped on it? This new API is how they've unified it across all the platforms
r
yes, it is 2.8.0
b
So it wasn't a better solution to what you were trying to do?
r
i didn't get that
file name is: AccountBookUiViewController
the lifecycle is working perferctly for desktop, android as well but not ios
With the lifecycle API this is how they've mapped them
r
please try now with branch
just pushed
yes, i went through this
b
I don't know why what youre doing doesn't work. I'm asking you why you didn't try the suggested answer
👍 1
m
The Lifecycle KMP seems to cover your use case, as pointed out by Ben and the answer in your stack overflow question. Please try it with the correct versions and if it doesn't work, please file a bug. cc: @Ivan Matkov
r
i mean to say, when i move away from app, "viewDidDisappear", other lifecycle methods of ios should be called
ok, i wil file a bug there, thanks for your time and quick revert
b
You are not trying to do what we are asking you to do. Please try with the KMP Lifecycle API. You are not currently using it. I gotta run. Best of luck.
r
Ah, we are getting diverged here, you are talking about composable lifecycle, which is working fine, but this question is related to app lifecycle, where "viewDidDisappear", other lifecycle methods of ios is not getting called other than "viewDidLoad, viewWillAppear, and viewDidAppear"