开发者

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.


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;
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜