iPhone - Track cellular data usage

谁都会走 提交于 2019-11-29 12:11:08

问题


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.


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/6607251/iphone-track-cellular-data-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!