Mr.P
Mr.P

Reputation: 1440

Sending data between two iOS devices with one acting as an iBeacon

So I've got two iOS devices, an iPad and an iPhone. I have the iPad acting as an iBeacon and the phone picking it up and ranging correctly and that's all going swimmingly.

What I want to achieve is for the phone to send the iPad a single string once it has been picked up as CLProximityImmediate.

Is this possible and if so, anyone know how to implement it?

Upvotes: 1

Views: 700

Answers (2)

David Hoerl
David Hoerl

Reputation: 41652

I'm doing this now too. I started off using MultiPeer Connectivity as suggested by Felz. However, I was forced into an architecture that would support Android as well, so I switched to BlueTooth. The iPad acting as an iBeacon also has BlueTooth code that is looking for "peripherals" with a certain signature.

Once the iPhone detects the iBeacon, the app then starts transmitting a BlueTooth peripheral signal with the appropriate signature. It uses characteristics to provide amount other things the user's ID (as supplied to the app earlier) - it could also supply the device type, etc.

When the iPad detects the peripheral, it reads the characteristics, then writes to a writeable characteristic to tell the iPhone "Hey, I got your info - you can shut down your Bluetooth transmit signal now".

I should add that in the end, it took me several hours to get MultiPeer networking working on both transmitter and receiver, and several days to get the BlueTooth code working (I'm doing this in Swift, and the BlueTooth classes have not been all that kind to Swifters - at least one bug on this still open even in latest iOS9 betas). But, it makes my boss happy since it will allow Android devices to play too!

Upvotes: 2

fsaint
fsaint

Reputation: 8759

Location services do not include data transfers. Try the Multipeer Connectivity framework.

Upvotes: 0

Related Questions