Search code examples
iosios7

Is there a cellular data usage API in iOS 7?


iOS 7 introduced a new user configuration to disable cellular data for specific apps. It can be configured in "Settings"->"Cellular" and then scrolling down.

settings screenshot

You'll find a switch for each installed app and can see how much cellular data it has consumed.

How can I programmatically test if the switch is turned on for my app? Is there an API for that? Can I determine how much data my app has used over cellular?

I'm not asking to get the values for all apps. I'm only interested in my apps usage.


Solution

  • There is no API to detect your download consumption or whether cellular is active for your app.

    If your app tries to connect to a website, but cellular is turned off, then iOS may ask the user to turn cellular back on. I'm not exactly sure how that works, but it is probably similar to the iOS 6 "no network connection" alert that would pop up if there is no connection but an app tries to access the internet.

    You can check if the current internet connection is over WiFi or Cellular, but if Cellular is disabled you will just be told that there is no network connection.

    More details here: iOS Detect 3G or WiFi