iOS 7 中是否有蜂窝数据使用 API? [英] Is there a cellular data usage API in iOS 7?

查看:11
本文介绍了iOS 7 中是否有蜂窝数据使用 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

您会为每个已安装的应用找到一个开关,并可以看到它消耗了多少蜂窝数据.

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

如何以编程方式测试我的应用的开关是否打开?有没有相关的 API?我可以确定我的应用通过蜂窝网络使用了多少数据吗?

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.

推荐答案

没有 API 来检测您的下载消耗或您的应用是否激活了蜂窝网络.

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

如果您的应用尝试连接到某个网站,但蜂窝网络已关闭,则 iOS 可能会要求用户重新打开蜂窝网络.我不确定它是如何工作的,但它可能类似于 iOS 6无网络连接"警报,如果没有连接但应用程序尝试访问互联网,则会弹出该警报.

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.

您可以检查当前的互联网连接是通过 WiFi 还是蜂窝网络连接,但如果蜂窝网络被禁用,您只会被告知没有网络连接.

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.

此处有更多详细信息:iOS 检测 3G 或 WiFi

这篇关于iOS 7 中是否有蜂窝数据使用 API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆