12

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.

Klaas
  • 22,394
  • 11
  • 96
  • 107
  • I found a thread on the Apple developer forums that mentions this. But there seems to be no API. See here https://devforums.apple.com/message/855240 – Klaas Oct 03 '13 at 23:41
  • I am working on a iPad App, but none of my apps in my iPad are showing under "Cellular Data Usage", my client want to show our App under that option. How can i show that? I am using iPad3 with a valid sim. – Sudheer Kumar Palchuri Nov 22 '13 at 09:34
  • @palchuri Are you sure, that your app has generate some traffic over the cellular network? – Klaas Nov 22 '13 at 12:04

2 Answers2

4

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

Community
  • 1
  • 1
Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110
1

You can't check if the cellular data switch is turned on.

  • The closest thing is that you can check if a specific host is reachable over cellular connection using the SCNetworkReachability kSCNetworkReachabilityFlagsIsWWAN flag.
  • Additionally, you can enable/disable cellular data for specific connections using the NSURLRequest allowsCellularAccess property.

Reference: https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/Platform-SpecificNetworkingTechnologies/Platform-SpecificNetworkingTechnologies.html

This answer suggests how data usage can be measured system-wide: iPhone Data Usage Tracking/Monitoring

Community
  • 1
  • 1
jrc
  • 20,354
  • 10
  • 69
  • 64