user3623016 user3623016 - 3 months ago 16
Swift Question

Perform action when opening app for the second time

When I open the app it fires the events

form my View Controller but when I close it and run it again it does not call any of them.

Any idea?


You need to read up on application states. Here is a link I found online outlining the different states:

What you really want is to be notified when your app becomes active.

Probably the easiest way is to implement the function applicationDidBecomeActive() in your app delegate. That will be called when your app becomes active as the foreground app either on launch, or when it returns to the foreground as the active app.

Note that if you want that notification sent to some object other than the app delegate you can listen for the UIApplicationDidBecomeActive notification.