10

I want to read how much data from 3G every app uses. Is this is possible in iOS 5.x ? And in iOS 4.x? My goal is for example:

  • Maps consumed 3 MB from your data plan
  • Mail consumed 420 kB from your data plan

etc, etc. Is this possible?

EDIT: I just found app doing that: Data Man Pro

enter image description here

EDIT 2: I'm starting a bounty. Extra points goes to the answer that make this clear. I know it is possible (screen from Data Man Pro) and i'm sure the solution is limited. But what is the solution and how to implement this.

Jason McTaggart
  • 878
  • 1
  • 7
  • 18
Jakub
  • 13,712
  • 17
  • 82
  • 139

2 Answers2

8

These are just hints not a solution. I thought about this many times, but never really started implementing the whole thing.

  1. first of all, you can calculate transferred bytes querying network interfaces, take a look to this SO answer for code and a nice explanation about network interfaces on iOS;

  2. use sysctl or similar system functions to detect which apps are currently running (and for running I mean the process state is set to RUNNING, like the ps or top commands do on OSX. Never tried I just suppose this to be possible on iOS, hoping there are no problems with app running as unprivileged user) so you can deduce which apps are running and save the traffic stats for those apps. Obviously, given the possibility to have applications runnning in background it is hard to determine which app is transferring data.
    It also could be possible to retrieve informations about network activity per process/app like nettop does on OSX Lion, unfortunately nettop uses the private framework NetworkStatistics.framework so you can't dig something out it's implementation;

  3. take into account time;

My 2 cents

Community
  • 1
  • 1
GreyHands
  • 1,734
  • 1
  • 18
  • 30
  • 1
    Considering the odd inaccuracies reported by some Data Man users, it is probably just making "educated guesses" based on a mechanism similar or identical to the one you described. +1 – Toastor May 27 '12 at 10:28
1

No, all applications in iOS are sandboxed, meaning you cannot access anything outside of the application. I do not believe this is possible. Neither do I believe data-traffic is saved on this level on the device, hence apple would have implemented it in either the network page or the usage page in Settings.app.

Besides that, not everybody has a "data-plan". E.g. in Sweden its common that data-traffic is free of charge without limit in either size or speed.

Paul Peelen
  • 10,073
  • 15
  • 85
  • 168
  • OK besides data plan. If user don't have it i want to read every connection witch is not WiFi – Jakub May 10 '12 at 09:32
  • As mentioned, the apps are sandboxed, you cannot (*legally*) access anything outside of your own app's sandbox and what Apple's API's allow. You can check which connection *Your* app is using using Reachability, yet that does not answer your question. – Paul Peelen May 10 '12 at 09:34
  • I just found app doing that: http://itunes.apple.com/us/app/dataman-pro-real-time-data/id433617332?mt=8! I update my original post! – Jakub May 10 '12 at 09:44
  • Ok, then checkout this question. http://stackoverflow.com/questions/6607251/iphone-track-cellular-data-usage – Paul Peelen May 10 '12 at 10:02
  • _you cannot access anything outside of the application_ — this is not exactly true, check FSWalker app: http://code.google.com/p/fswalker/ – ivanzoid May 25 '12 at 16:24
  • @SimpleMan Did you do that if yes can you help me with this – Shashank Kulshrestha May 21 '13 at 13:02
  • @ShashankKulshrestha Sadly no. – Jakub May 21 '13 at 14:44