问题
I want to get cellular data usage details per application programmatically. Also, please note that, it should not be mandatory to be executed on jailbroken device. Please suggest some API.
回答1:
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.
回答2:
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;
}
来源:https://stackoverflow.com/questions/25619260/how-to-access-cellular-data-usage-statistics-per-application-programmatically-in