0

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?

gilsho
  • 921
  • 7
  • 11
  • applicationDidBecomeActive: is called: when app is first launched after application:didFinishLaunchingWithOptions: after applicationWillEnterForeground: if there's no URL to handle. after application:handleOpenURL: is called. after applicationWillResignActive: if user ignores interruption like a phone call or SMS. – maelswarm Oct 24 '14 at 22:13
  • possible duplicate of [applicationWillEnterForeground vs. applicationDidBecomeActive, applicationWillResignActive vs. applicationDidEnterBackground](http://stackoverflow.com/questions/3712979/applicationwillenterforeground-vs-applicationdidbecomeactive-applicationwillre) – maelswarm Oct 24 '14 at 22:13

0 Answers0