简体   繁体   English

如何在iPhone中以编程方式访问每个应用程序的蜂窝数据使用情况统计信息?

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

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. 请提出一些API。

There is no API to get this information on the device. 没有API可以在设备上获取此信息。 But you can use Charles Proxy to get traffic numbers and traffic itself. 但是您可以使用Charles Proxy来获取流量数字和流量本身。 You can find implementation details about Charles Proxy in this tutorial article . 您可以在本教程文章中找到有关Charles Proxy的实现详细信息。 It's possible to implement your own app that behaves as MITM proxy. 可以实现您自己的充当MITM代理的应用程序。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM