0

I am developing iPhone app where I want to display how much data downloaded and uploaded from device. I didn't find any public APIs to do this. But I fount one app 'OpenSignal' which does the same thing. here is the link for OpenSignal app.

Any help how to detect how much data downloaded or uploaded from the device.

Any help?

iAsh
  • 447
  • 6
  • 19
  • How are you doing your uploads and downloads? The API does tell you. You can also approximate because you set the data to be sent and process the received data. – Wain Sep 20 '13 at 10:21
  • It's not related to app download or upload. It's related to device download and upload data. For example: Open my app downloaded data =38.9mb -> Close app also from background ->Open YouTube -> download video -> open my app then downloaded data=48.0 mb. – iAsh Sep 20 '13 at 10:38
  • That is not what `OpenSignal` app seems to do. – Wain Sep 20 '13 at 11:15
  • Yes it is. Go to MyState tab in OpenSignal. I tried above execution path with OpenSignal app. – iAsh Sep 20 '13 at 11:34

1 Answers1

1

This can be done using getifaddrs. You will need to iterate and search for the appropriate data. You're looking for a record where sa_family == AF_LINK and then you can check which interface it is part of and get the number of bytes. There are restrictions such as when this record gets wiped to zero. man page (google is also your friend for usage details).

Wain
  • 118,658
  • 15
  • 128
  • 151
  • Is it allowed by Apple. I want to upload app to the AppStore. [here](http://stackoverflow.com/questions/7946699/iphone-data-usage-tracking-monitoring?answertab=votes#tab-top) is the link what I found. – iAsh Sep 20 '13 at 12:45
  • I believe it's a public API so it should be fine. – Wain Sep 20 '13 at 13:42