Bidirectional Exchange of JSON between two iOS devices

I have a use case where I have two iOS devices that needs to exchange JSON objects between each other. It is a bidirectional flow of data and the request can trigger from each device at any point of time. I would like to understand if I can achieve this using CoreBluetooth? I have checked multipeer connectivity and although that does do the Job for me, it seems an overkill since I don't have multiple peers. I have a set of devices that will always be talking to one other device i.e, 1:1 mapping of all the devices that I have and there is no cross connection.

You are correct that you shouldn’t use Multipeer Connectivity for this.

That is not, however, the only way to do peer-to-peer Wi-Fi. You can just as easily do that using Network framework. For a concrete example, see the Building a custom peer-to-peer protocol sample code.

As to whether you should use this or Core Bluetooth, that kinda depends. Keep in mind that Bluetooth LE is really slow, so if you need to transfer large values, or lots of small values quickly, I’d recommend Wi-Fi.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo, Thanks for the response.

You are correct that you shouldn’t use Multipeer Connectivity for this.

Would you be saying this just because it is an overkill to use MPC here or is there any other reason? From what I currently understand, MPC can get the job done for me without me having to write a lot of low level coding that Network framework requires me to do mentioned in the link that you shared. I had ruled out Network framework for the reason that I need to be quick to market :) and MPC/CoreBluetooth offers a higher level of abstraction compared to Network framework.

is there any other reason?

Yes. Multipeer Connectivity has, as the name suggests, a multipeer architecture. It works best when there’s a group of peers that come and go and need to exchange small chunks of data with low latency. The canonical example of this is a network-based game. My experience it’s that it’s not a great match for other network scenarios.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Bidirectional Exchange of JSON between two iOS devices
 
 
Q