简体   繁体   中英

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.

I've seen quite a few programmatic answers to my questions such as the following:

iPhone Data Usage Tracking/Monitoring

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:

在此输入图像描述

Every time I navigate the app using my own device, I see a change in receiving/sending rates in 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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