How to access cellular data usage statistics per application programmatically in iphone?

Deadly 提交于 2019-12-03 10:45:48

There is no API to get this information on the device. But you can use Charles Proxy to get traffic numbers and traffic itself. You can find implementation details about Charles Proxy in this tutorial article. It's possible to implement your own app that behaves as MITM proxy.

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