I am trying to accurately track sessions in our app, and I would like to understand how I can determine if an app open was initiated by a user, as opposed to the operating system.
I define 'session' as when the app has entered the foreground -- this may happen from interacting with a remote or local notification, explicitly opening the app, tapping a deep-link, etc.
Currently I consider a new session every time applicationDidBecomeActive
gets called, but that can be initiated by the operating system periodically when it refreshes the app.
I don't want to use willEnterForeground
because it's not called when the app is first opened.
I don't want to use didFinishLaunchingWithOptions
either because it gets called when a push notification occurs.
It looks like applicationDidBecomeActive
is where this code should live, but how do I know when it is called by the system and not by the user action?