Reputation: 1394
How will I know in appDidBecomeActive that 1. app is launched from the background 2. app is killed and launched from menu again.
How can I differentiate between these two?
Upvotes: 0
Views: 88
Reputation: 318794
When an app is fully relaunched, didFinishLaunchingWithOptions
is called. When returning from the background, didEnterForeground
is called.
Keep in mind that didBecomeActive
can be called in other cases besides those two. A system alert might appear while the user is using your app. When the alert is dismissed, your app becomes active again. And in this case it wasn't in the background and it wasn't relaunched.
The only way for didBecomeActive
to know why it became active is to set a flag in didFinishLaunchingWithOptions
and didEnterForeground
and check that value in didBecomeActive
.
Upvotes: 2