I need to send, and receive, a JSON string between an iOS device and an Android device. Both devices will be on the same router. The iOS device will initiate the connection and the ipAddress of the Android device is static and will be known to the iOS device. What is the best way to do this?
Communicating iOS to Android
On the iOS side, there is a couple of APIs to approach this and both of them would include Bonjour in a peer-to-peer setting. The basic idea is that you would discover the Android Bonjour service running on your router (local network) and communicate and use that service to send and receive data between devices. This means that Android would be discovering and using the same Bonjour Network Service Discovery service as well.
On the iOS side, take a look at this documentation to get started:
- (WWDC 2019) https://developer.apple.com/documentation/network/building_a_custom_peer-to-peer_protocol
- (NWBrowser) https://developer.apple.com/documentation/network/nwbrowser
- (Bonjour Development) https://developer.apple.com/bonjour/
- (NSNetService) https://developer.apple.com/documentation/foundation/nsnetservice