简体   繁体   中英

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. Precise location isn't necessary, but they should be in a 30ft radius.

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. I would use iBeacons, but I understand they cannot transmit/advertise in the background.

  2. Use GPS: This works in the background, no problem. However, the accuracy is sketchy, and in doors its much worse.

The questions I have, for the more experienced ios programmers, are this:

  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? 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. Refer: [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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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