Transmitting data using iBeacon or similar technol

2019-03-01 06:21发布

问题:

I am working on an app that allows devices to become aware of each other when in range. To do this i am using iBeacon.

In the next stage of development i want to be able to send a yes or no string between any of the devices in range - so anyone who is connected to any other iBeacon can communicate these fixed messages

As iBeacon cannot support sending of data - what is the best approach to facilitate this. The 2 approaches i have at the moment are via bluetooth or a web service.

Please could someone provide some advise on to what is the best approach.

回答1:

Either approach can work, but a web service has real advantages:

  1. Connecting to a bluetooth service requires user permission, a web service does not.

  2. If your app is not running in the foreground, the iBeacon monitoring API can make it launch into the background for about 5 seconds. During this time you can call a web service. But background support for bluetooth connections is limited in iOS.

  3. If the bluetooth connection is directly between devices, you have to figure out which device to make the central and which to make the peripheral. This negotiation is complex.

  4. If the bluetooth connection is between each device and the beacon, then you can't use standard iBeacons -- you have to build custom ones that support additional connectable bluetooth services.

The main disadvantage of a web service approach is that it won't work when you don't have network connectivity. You have to decide if you can live with that disadvantage.