What should I use to track how long is user using my application on iOS devices?
I think I can do it like this:
application:didFinishLaunchingWithOptions:
)applicationWillTerminate:
)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:
and applicationWillEnterForeground:
More here.
I believe that calculating the time on the device itself would be best, considering you want this to be network and resource effective. The calculation of endTime - starTime will be very very fast (depending on your time implementation), and then you would only need to send one piece of data (the time it took) over a network instead of two (the start and end times).
Hope this helps! N.S.
Seems like a reasonable way to do it. It's efficient enough, and depending on how you see the data, it shouldn't be more than a kilobyte or two, if that. Be wary of privacy issues though—users are really against being logged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With