Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - Track cellular data usage

Is there a way to track cellular data usage on iPhone ? There are lot of apps which does the same like 'Dataman' and 'DataUsage'

Basically I am looking for a programmatic way to get information stored in Settings -> General -> Usage

Any help will be appreciated.

like image 370
Unicorn Avatar asked Jul 07 '11 07:07

Unicorn


People also ask

Can you see what cellular data was used for?

Track and Manage Your Data Usage Scroll down to the Cellular Data section, and you'll see the amount of data used in the current period so far. On an Android device (4.0 and higher), you'll go to Settings→Network & Internet→Data Usage.

Does iPhone have a data tracker?

Apple allows you to track your cellular data usage stats right from its in-built Settings. To access the native data tracker, you have to open Settings > General > Usage. This tab will display you a summary of your billing cycle and the total data sent and received through your iPhone.


2 Answers

To check Cellular 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;
}
like image 111
Sandeep Khade Avatar answered Oct 12 '22 22:10

Sandeep Khade


You could query each network interface for the data going through it.

like image 41
Eric Avatar answered Oct 12 '22 22:10

Eric