9

Possible Duplicate:
iPhone Data Usage Tracking/Monitoring

I'm trying to build a "Data Usage Monitoring" iphone app as a quick demo, but haven't been able to figure out how to get CellularData/Wifi usage statistics programmatically.

I know this is possible, as there are several apps in the app store for this (DataUsage, DataMan).

I know for a fact that these are not scrapping the cellular provider's pages to get the data usage, so I'm wondering how they are able to achieve this.

Couldn't find anything in the iOS 4.2 SDK Documentation.

I'm guessing they are somehow getting the data that is displayed under "Settings -> General -> Usage",

Community
  • 1
  • 1
DanyO
  • 91
  • 1
  • 2
  • 4
    [The answer can be found in this SO thread](http://stackoverflow.com/questions/7946699/iphone-data-usage-tracking-monitoring) – Lefteris Sep 18 '12 at 09:16

1 Answers1

0

Hey, this is sort of untested - I tried it on the simulator, but it obviously doesn't store any data usage statistics. Try to give this code a shot on an iPhone device.

NSLog(@"Contents of the user defaults: %@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);

It should print out the entire contents of the users preferences. You should then be able to dig out the appropriate keys for accessing the data you need.

Tell me whether it works or not :D

  • Doesn't show in NSUserDefaults of the device (4.3). It shows only values for NSInterfaceStyle, NSLanguages, AppleKeyboards, AppleLocale, AppleITunesStoreItemKinds, AppleKeyboardsExpanded and AppleLanguages – Sahil Khanna Oct 25 '11 at 09:43