13

I want to get cellular data usage details per application programmatically. Also, please note that, it should not be mandatory to be executed on jailbroken device. Please suggest some API.

Vinay Bagale
  • 2,361
  • 4
  • 36
  • 45
  • 1
    Someone else posted some code on how to get cellular data but not broken down for each app specifically. But if you want to check it out.. http://stackoverflow.com/a/14556206/1922144 – davidcondrey Sep 02 '14 at 08:46
  • 1
    possible duplicate of [iPhone Data Usage Tracking/Monitoring](http://stackoverflow.com/questions/7946699/iphone-data-usage-tracking-monitoring) – davidcondrey Sep 02 '14 at 08:47
  • @dcc sorry, but i could not find it relevant. That does not answer my question. please share link if you find it more relevant. Need data usage details per app. – Vinay Bagale Sep 02 '14 at 08:54
  • In the comments of this answer http://stackoverflow.com/a/8014012/1922144 there is chatter about the provided code being used to display data on a per app basis I believe.. Best info I could find for you so far, hope it helps.. – davidcondrey Sep 02 '14 at 08:57
  • 1
    Thanks @dcc i tried this code before posting this question. It only returns total data usage either by WIFI or WWAN. App wise data usage is discussed but not shared any code by author. – Vinay Bagale Sep 02 '14 at 09:29
  • @VinayBagale - Have you got solution ? – Durai Amuthan.H Feb 18 '16 at 13:21
  • 1
    @DuraiAmuthan.H - Unfortunately not able to get the answer yet. – Vinay Bagale Feb 18 '16 at 16:45
  • @VinayBagale - Its good you declared a bounty on this.. – Durai Amuthan.H Feb 19 '16 at 06:12
  • 1
    Hey Vinay, i think there is no way to measure data you are using outside of your app. – Suhas Arvind Patil Feb 24 '16 at 11:29
  • There should a way as apple is doing that in there setting apps – Adnan Aftab Nov 20 '16 at 20:34
  • 1
    http://stackoverflow.com/questions/5274805/iphone-ipad-data-usage-tracking checkout codebreaker answer, that make sense. – Adnan Aftab Nov 20 '16 at 20:39
  • @AdnanAftab Apple can do, but this does not means "all" can do. Apple of course controls the whole device, developers must move within their app boundary. – carmine Jan 26 '17 at 09:17
  • The comment by @AdnanAftab should be the correct answer. You have to intercept all network requests and inspect them to figure out which app initiated the request. If you route all the requests through your own proxy server than you'd know the cellular data usage per app. You might be able to do this without needing a proxy server using just the request meta data? not sure. I would be surprised if there were any other way to do this since apps are sandboxed and Apple doesn't provide a public API giving this information. I'd be surprised if there were even a private Apple API that does this. – Lobsterman Jul 21 '17 at 19:58

2 Answers2

0

There is no API to get this information on the device. But you can use Charles Proxy to get traffic numbers and traffic itself. You can find implementation details about Charles Proxy in this tutorial article. It's possible to implement your own app that behaves as MITM proxy.

Evgen Bodunov
  • 5,438
  • 2
  • 29
  • 43
0
To check celular network use this
- (bool) hasCellular {
    struct ifaddrs * addrs;
    const struct ifaddrs * cursor;
    bool found = false;
    if (getifaddrs(&addrs) == 0) {
        cursor = addrs;
        while (cursor != NULL) {
            NSString *name = [NSString stringWithUTF8String:cursor->ifa_name];
                if ([name isEqualToString:@"pdp_ip0"]) 
                    found = true;
            }
            cursor = cursor->ifa_next;
        }
        freeifaddrs(addrs);
    }
    return found;
}
stephen
  • 78
  • 12