简体   繁体   中英

Can an iOS device monitor its own beacon (one that it is advertising)?

I am hoping I can make an iOS app run a self-test to see if it's able to listen to beacons, by:

  1. Advertising a beacon (with a randomly-generated UUID) via the CBPeripheralManager API, and
  2. Monitoring and ranging for that same beacon.

In other words, make the device listen for the beacon that it, its very self, is advertising.

I do get a success response when I start advertising: the system calls my peripheralManagerDidUpdateState handler with peripheral.state set to PoweredOn .

I also get a success response when I start monitoring for beacons: the system calls my locationManager:didStartMonitoringForRegion: handler. I also get locationManager:didRangeBeacons:inRegion: calls.

However, it always gives me a zero-length list of beacons in range.

Does anyone know: does iOS prevent a device from monitoring or ranging itself as a beacon?

Unfortunately, no. Neither CoreLocation nor CoreBluetooth will pick up an advertisement transmitted by the same device. This should not really be surprising as the device has a single Bluetooth radio, so it cannot transmit and receive at the same time.

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