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

前端 未结 2 577
借酒劲吻你
借酒劲吻你 2021-02-13 10:09

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 sugges

2条回答
  •  感情败类
    2021-02-13 10:27

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

提交回复
热议问题