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

查看:129
本文介绍了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还是Cellular,但如果禁用Cellular,您将被告知没有网络连接。

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

More details here: iOS Detect 3G or WiFi

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

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