ios iOS7 设备可以充当 iBeacon 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19274286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:14:28  来源:igfitidea点击:

Can an iOS7 device act as an iBeacon?

iosios7bluetooth-lowenergyibeacon

提问by Andrei

Can an iOS7 device act as an iBeaconand figure out when other iOS7 devices come in its range? Do those other iOS7 devices need to have Bluetooth turned on?

iOS7 设备能否充当iBeacon并确定其他 iOS7 设备何时进入其范围?其他 iOS7 设备需要开启蓝牙吗?

回答by Mike Pollard

An iOS device with BluetoothLE can act as an iBeacon yes.

带有 BluetoothLE 的 iOS 设备可以充当 iBeacon 是的。

Check out the AirLocate example code at https://developer.apple.com/downloads/index.action?name=WWDC%202013#

https://developer.apple.com/downloads/index.action?name=WWDC%202013#查看 AirLocate 示例代码

Being an iBeacon doesn't give feedback about devices that come into range so you'd have to implement that yourself. ie you'd have to have the devices that detect the iBeacon then tell the iBeacon they'd seen it through some other means.

作为 iBeacon 不会提供有关进入范围的设备的反馈,因此您必须自己实施。也就是说,您必须让设备检测到 iBeacon,然后告诉 iBeacon 他们通过其他方式看到了它。

回答by Joris Kluivers

Yes, an iOS device can act as a beacon, from iPhone 4s and up (Bluetooth 4.0 required).

是的,iOS 设备可以作为信标,从 iPhone 4s 开始(需要蓝牙 4.0)。

You publish a beacon by passing the dictionary from [CLBeaconRegion peripheralDataWithMeasuredPower:]to [CBPeripheralManager startAdvertising:].

您通过将字典从[CLBeaconRegion peripheralDataWithMeasuredPower:]to传递来发布信标[CBPeripheralManager startAdvertising:]

Publishing a beacon will not give you any feedback on devices, you'll have to scan for others publishing a beacon.

发布信标不会给您任何设备反馈,您必须扫描其他发布信标的人。

As for backgrounding, you can not publish a beacon in the background, your app needs to be running in the foreground for that. Scanning is possible in the background.

至于后台,您不能在后台发布信标,您的应用程序需要为此在前台运行。可以在后台进行扫描。

回答by davidgyoung

Yes, an iOS7 device can act as an iBeacon. You can do exactly what you are suggesting if you have an app installed on all phones, and you also write a web service. This would allow phone A to see phones B and C when they are nearby:

是的,iOS7 设备可以充当 iBeacon。如果您在所有手机上都安装了一个应用程序,并且您还编写了一个网络服务,那么您就可以完全按照您的建议去做。这将允许电话 A 在附近时看到电话 B 和 C:

  1. Your app on Phone A acts as an iBeacon advertising its presence.
  2. Phones B and C see this iBeacon, waking up your app to make a call to your web service reporting that they both see Phone A's transmission.
  3. Your app on Phone A queries this web service, which returns a list of phones that see Phone A. In this example, the list includes Phones B and C. Your app updates its display with this list.
  1. 您在电话 A 上的应用程序充当 iBeacon 广告其存在。
  2. 电话 B 和 C 看到此 iBeacon,唤醒您的应用程序以调用您的网络服务,报告他们都看到了电话 A 的传输。
  3. 您在电话 A 上的应用程序查询此 Web 服务,该服务返回看到电话 A 的电话列表。在此示例中,列表包括电话 B 和 C。您的应用程序使用此列表更新其显示。

All phones would need Bluetooth LE, have it turned on, and have your app installed. They would also need internet connectivity to call the web service.

所有手机都需要蓝牙 LE,将其打开并安装您的应用程序。他们还需要 Internet 连接来调用 Web 服务。

回答by Laura

If you're not set on using iBeacons, this project uses Bluetooth LE to share an array of ids between nearby phones- SimpleShare

如果你没有开始使用 iBeacons,这个项目使用蓝牙 LE 在附近的手机之间共享一组 id- SimpleShare

You could set an ID for the user of each phone, share them between the phones over Bluetooth LE using the SimpleShare project (even while in background mode), and then query a web service to find out more information about the user with that ID.

您可以为每部手机的用户设置一个 ID,使用 SimpleShare 项目通过蓝牙 LE 在手机之间共享它们(即使在后台模式下),然后查询 Web 服务以查找有关具有该 ID 的用户的更多信息。

回答by brontus

As mentioned, an iOS 7 device canact as an iBeacon, so long as it Bluetooth LE technology.

如前所述,只要支持蓝牙 LE 技术,iOS 7 设备就可以充当 iBeacon。

To use iBeacon, you need iOS 7 or later, Bluetooth turned on, and a compatible iOS device:

  • iPhone 4s or later
  • iPad (3rd generation) or later
  • iPad mini or later
  • iPod touch (5th generation) or later.

要使用 iBeacon,您需要 iOS 7 或更高版本,打开蓝牙,以及兼容的 iOS 设备:

  • iPhone 4s 或更新机型
  • iPad(第 3 代)或更新机型
  • iPad mini 或更新机型
  • iPod touch(第 5 代)或更新机型。

http://support.apple.com/kb/HT6048

http://support.apple.com/kb/HT6048

回答by Markus Rautopuro

One point that didn't come out clearly from the previous answers is that in order for the publishing to work (for example in David's answer's Phone A) the application that started publishing must be in foreground.

从之前的答案中没有明确指出的一点是,为了使发布工作(例如在 David 的回答的电话 A 中),开始发布的应用程序必须在前台。

From the Apple documentation:

从苹果文档

While your app is in the background, the local name is not advertised and all service UUIDs are placed in the overflow area.

当您的应用程序在后台时,本地名称不会被广告,所有服务 UUID 都放在溢出区域。