简体   繁体   English

跟踪在应用程序中花费的时间

[英]Track time spent in application

What should I use to track how long is user using my application on iOS devices?我应该使用什么来跟踪用户在 iOS 设备上使用我的应用程序的时间?

I think I can do it like this:我想我可以这样做:

  1. Log time on App startup ( application:didFinishLaunchingWithOptions: )应用程序启动时的记录时间 ( application:didFinishLaunchingWithOptions: )
  2. Log time on App ending ( applicationWillTerminate: )应用程序结束时的记录时间( applicationWillTerminate:
  3. 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.) (不要在复杂的计算操作上发送大量数据或消耗 iOS 资源。)

Notice that applicationWillTerminate: is not necessarily called when the home button is pressed (this changed from iOS 3.X to iOS 4.0).请注意,当按下主页按钮时,不一定会调用applicationWillTerminate:这从 iOS 3.X 更改为 iOS 4.0)。

Take a look at applicationDidEnterBackground: and applicationWillEnterForeground:看看applicationDidEnterBackground: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). endTime - starTime 的计算将非常非常快(取决于您的时间实现),然后您只需要通过网络发送一个数据(所花费的时间)而不是两个(开始和结束时间) .

Hope this helps.希望这可以帮助。 NS NS

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.不过要警惕隐私问题——用户确实反对被登录。

Your method is sound, it will have next to no overhead and get the job done nicely.您的方法是合理的,它几乎没有开销并且可以很好地完成工作。

  1. Log time on App startup (didFinishLaunchingWithOptions)应用程序启动时的日志记录时间 (didFinishLaunchingWithOptions)
  2. send report often with interval of 5min.经常以 5 分钟的间隔发送报告。
  3. send report in applicationWillEnterbackground.(pause timer(invalidate) if u used background thread for it).because if the user enter in other app then they can close ur app by just using home button and with minus button in app manager.so u have to send report here also在 applicationWillEnterbackground 中发送报告。(如果您使用后台线程,则暂停计时器(无效))。因为如果用户进入其他应用程序,那么他们可以通过使用主页按钮和应用程序管理器中的减号按钮来关闭您的应用程序。所以你有也在这里发送报告
  4. resume timer with previous time in applicationWillEnterForeground.在 applicationWillEnterForeground 中以先前时间恢复计时器。
  5. Log time on App ending (applicationWillTerminate)应用程序结束时的记录时间 (applicationWillTerminate)
  6. Send report (pairs of start/exit time) to server and count time spent in app将报告(开始/退出时间对)发送到服务器并计算在应用程序中花费的时间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何跟踪花费在移动应用浏览量上的时间 - How to track time spent on mobile app views 如何跟踪用户在Google Analytics屏幕上花费的时间 - how to track that how much time user spent on a screen Google Analytics 如何在iOS中计算在后台花费的时间应用程序 - How to calculate time application spent in background in iOS 我如何在目标 c 中跟踪应用程序花费的时间 - How I can Track application spend Time in objective c 确定UIImageView“绘图”花费时间的方法? - Methods to determine time spent 'drawing' by UIImageView? 使用NSNotificationCenter计算应用程序在后台花费的时间 - Counting time spent in background for an app using NSNotificationCenter 在prepareForSegue中执行代码所花费的时间比在viewWillAppear结束之前花费的时间更长 - Time spent to execute code in prepareForSegue longer than the one spent till the end of viewWillAppear 计算跨多个View Controller iOS花费的时间 - Count Time Spent across multiple view controllers ios 有没有一种方法可以衡量用户在我的应用中花费的总时间? - Is there a way to measure the total time the user has spent in my app? 如何衡量在iOS中花费的网络时间细分? - How can I measure the breakdown of network time spent in iOS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM