简体   繁体   English

如何以编程方式或其他方法跟踪我的iOS应用程序的手机数据使用情况?

[英]How to keep track of cellular data usage of my iOS app programmatically or with other methods?

I have noticed that from the Settings that my app uses quite a bit of cellular data and this needs to be fixed before submitting to the App Store. 我注意到,从设置中我的应用程序使用了相当多的蜂窝数据,这需要在提交到App Store之前修复。

I've seen quite a few programmatic answers to my questions such as the following: 我已经看到了很多关于我的问题的程序化答案,如下所示:

iPhone Data Usage Tracking/Monitoring iPhone数据使用跟踪/监控

I have also searched for all other related postings. 我还搜索了所有其他相关帖子。 However, when I tried testing my app by implementing techniques from said postings, they did not really do anything. 但是,当我尝试通过实施所述帖子的技术来测试我的应用程序时,他们并没有真正做任何事情。 I looked at the changes in downloaded/uploaded bytes, but they stayed the same and that's wrong because according to cellular data information from the Settings, my app is hemorrhaging cellular data. 我查看了下载/上传字节的变化,但它们保持不变,这是错误的,因为根据设置中的蜂窝数据信息,我的应用程序正在大量出现细胞数据。

I see this in the Xcode: 我在Xcode中看到了这个:

在此输入图像描述

Every time I navigate the app using my own device, I see a change in receiving/sending rates in KB/s. 每次我使用自己的设备导航应用程序时,我都会看到接收/发送速率的变化,单位为KB / s。 This is great in tracking what part of the app uses data. 这非常适合跟踪应用程序的哪些部分使用数据。

Instead of simulating location on my device, I want to be able to use actual location data, which will download location information, but I can't seem to do that when debugging it on Xcode. 我希望能够使用实际位置数据来下载位置信息,而不是在我的设备上模拟位置,但是在Xcode上调试时我似乎无法做到这一点。 When I end the debugging session and run the app on my own, then I would have no clue how much exactly data would map part of app consume. 当我结束调试会话并自己运行应用程序时,我就不知道究竟有多少数据会映射应用程序消耗的部分内容。 Is there any other effective way to learn about data usage? 有没有其他有效的方法来了解数据使用情况?

I have discovered a method which gives me a good idea on when and what of this issue. 我发现了一种方法,可以让我对这个问题的时间和内容有所了解。 If you scroll right on the Network Report, you would see a button called "Profile in Instruments" on the top right corner. 如果您在网络报告上向右滚动,您会在右上角看到一个名为“仪器中的配置文件”的按钮。

Network Report 网络报告

If you press it, it will take you to a program called Instruments. 如果你按它,它将带你到一个名为仪器的程序。 It looks like this: 它看起来像这样:

Instruments 仪器

Play around with your app and see the changes in internet traffic. 使用您的应用程序,看看互联网流量的变化。 With this, you can narrow down where your cellular data is consumed. 有了这个,您可以缩小细胞数据消耗的范围。 If you narrow down on the culprits (ViewControllers) that eats up your cellular data, then you can examine your code and do something about it. 如果您缩小了消耗细胞数据的罪魁祸首(ViewControllers),那么您可以检查代码并对其进行一些操作。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM