What should I use to track how long is user using my application on iOS devices?
I think I can do it like this:
- Log time on App startup (
application:didFinishLaunchingWithOptions:) - Log time on App ending (
applicationWillTerminate:) - List item
Send report (pairs of start/exit time) to server and count time spent in app
Do you have any better ideas?
Important is to be network and resources effective
(not to send big amount of data or consume iOS resources on complex computing operations.)
Notice that
applicationWillTerminate:is not necessarily called when the home button is pressed (this changed from iOS 3.X to iOS 4.0).Take a look at
applicationDidEnterBackground:andapplicationWillEnterForeground:More here.