简体   繁体   English

如何确定两部iPhone之间的距离?

[英]How to determine how close two iPhones are to each other?

I'm working on an app that needs to have the ability to locate other iphones nearby. 我正在开发一款需要能够在附近找到其他iPhone的应用程序。 Precise location isn't necessary, but they should be in a 30ft radius. 不需要精确定位,但它们的半径应为30英尺。

Note: all of this has to happen in the background. 注意:所有这些都必须在后台进行。

The options, as I see it, are: 如我所见,这些选项是:

  1. Use Bluetooth. 使用蓝牙。 Develop a BT connection protocol that allows the app to send and receive data (just text) in the background. 开发一个BT连接协议,该协议允许该应用在后台发送和接收数据(纯文本)。 I would use iBeacons, but I understand they cannot transmit/advertise in the background. 我会使用iBeacons,但我知道它们无法在后台传输/广告。

  2. Use GPS: This works in the background, no problem. 使用GPS:这在后台工作,没问题。 However, the accuracy is sketchy, and in doors its much worse. 但是,精度是粗略的,并且在门内精度要差得多。

The questions I have, for the more experienced ios programmers, are this: 对于更有经验的ios程序员,我有以下问题:

  1. Does an app that uses bluetooth, or any kind of bluetooth, always need to have the bluetooth on? 使用蓝牙或任何种类的蓝牙的应用程序是否始终需要打开蓝牙? And can it request that the user do so? 并可以要求用户这样做吗?

  2. If iPhone GPS gets the location wrong, does it show the same wrong location on another iPhone right next to it? 如果iPhone GPS的位置错误,它是否在旁边的另一部iPhone上显示相同的错误位置? I have no need for the actual position of the user...if the locations are "wrong" but they are the same I can tell they are close and that's enough for me. 我不需要用户的实际位置...如果位置“不正确”,但它们相同,我可以告诉他们它们靠近,对我来说足够了。

Any help at all would be appreciated! 任何帮助将不胜感激! Thanks! 谢谢!

@1, Bluetooth : scanForPeripheralsWithServices method returns list of nearby bluetooth enabled devices. @ 1,蓝牙:scanForPeripheralsWithServices方法返回附近启用了蓝牙的设备的列表。 Refer: [https://developer.apple.com/library/mac/samplecode/HeartRateMonitor/Listings/HeartRateMonitor_HeartRateMonitorAppDelegate_m.html][1] 请参阅:[https://developer.apple.com/library/mac/samplecode/HeartRateMonitor/Listings/HeartRateMonitor_HeartRateMonitorAppDelegate_m.html][1]

@2, In indoor, GPS returns Last known location until it will get new location @ 2,在室内,GPS返回最后一个已知位置,直到获得新位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM