Can*_*Can 3

长话短说

这绝对不是在 AppStore 上的生产应用程序上实现的目标,但您可以使用私有 API 为自己实现一些概念验证。

详细版本

在 iOS 上,有一些 API 用于读取RSSI附近 Wi-Fi 网络的值和其他此类操作,但最不幸的是,它们并不公开。

Apple 将 API 区分为公共 API 和私有 API。开发人员可以使用的(公共的)并将应用程序发送到 AppStore 的文档记录在developer.apple.com中。

其他 API(私有 API)并未由 Apple 公开记录。这样做的原因主要归结为苹果希望以更全面的方式控制 iOS 的各个方面:

  • 一些 API 尚不存在,因此它们仅用于 Apple 自己的内部开发和测试,
  • Apple 不希望 iOS 的某些方面被滥用并随着时间的推移而成熟(例如用于操纵拍照方面的相机 API),
  • 当然,苹果有一个赚钱的议程,他们根据自己的需要使用这些 API。

该怎么办

如上所述,如果您知道自己在做什么,则仍然可以访问私有 API 。

基本思想是,由于公共和私有 API 都在 iOS 中使用(无论是由一般开发人员还是 Apple),因此它们都应该位于runtime. 您所需要的只是一个将它们捞出来的工具。这个工具就是RunTimeBrowser。该项目的维护者 Nicolas Seriot 也将他的发现作为 GitHub 存储库发布在这里。

如果您查看这些发现,您将能够找到适当的 API 来检索RSSI附近 Wi-Fi 网络的值。

然而,我应该提前警告您,这并不像听起来那么容易。一旦找到合适的 API,事情还不止于此:

  • 首先,在 iOS 上,某些框架需要某些权利。因此,当您为所需的 API 找到必要的私有框架时,您还需要弄清楚它的权利并将其注入到您的项目中。这是/不容易获得的,
  • Integrating private frameworks into a project is not as straightforward as integrating a public framework, say CoreLocation, since they're not documented and you will be walking blind with your guts,
  • Once you integrate a private framework, it's usage will be difficult as well both because of the above reasons and the possibility of Apple making changes to those private APIs. Of course, every API changes from time to time but Apple can break things apart as it wishes with private APIs since it never allowed you to use them in the first place. So, something you've spent long hours on could be for nothing in the future.

With all that being said as a warning(I really don't want to discourage you but you should see where you're headed), there is still work being done about private APIs either for personal usage or other reasons.

您可以查看Michael Dorner 的BeeTee,他在其中演示了如何使用BluetoothManager,这是一个在 iOS 上控制蓝牙的私有框架。

通过该项目的学习,您可以将这些知识应用于读取RSSI附近 Wi-Fi 网络的值。请记住,您无法在 AppStore 上获得批准。

玩得开心!