iOS: How to check if cellular data usage is on for an app?
Asked Answered
K

1

6

In my app I want to be able to detect if the cellular data usage is on for a particular application, and depending on the result of the check act appropriately.

Is there a way to perform this programmatic check?

Knopp answered 6/11, 2014 at 2:26 Comment(1)
Answer: Use the well-documented Reachability framework provided by Apple.Each
Q
0

Go to the following link:

https://developer.apple.com/library/ios/samplecode/reachability/introduction/intro.html

download and import the header and iplementation file, then use this code:

Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus status = [reachability currentReachabilityStatus];

if (status == ReachableViaWWAN) 
{
    NSLog(@"Cellular data");
}

This project is a little old, you might need to turn ARC mode off see this answer:

How can I disable ARC for a single file in a project?

Quantum answered 6/11, 2014 at 3:10 Comment(1)
thank you for your answer! but this code checks if cellular is on. It doesn't check if cellular data is on for a specific app installed on the phone.Knopp

© 2022 - 2024 — McMap. All rights reserved.