How can an app send data to another phone?

I want to develop an iPhone app that can exchange small amounts of data with another copy of the same app, running on another phone, using the cellular network. It needs to work when the phones are not close together. The app on one phone must somehow find the other app cellularly and establish a communication channel or link to it. The apps need to exchange a small amount of data while they are running in the background. I'm not thinking of user-supplied data like a messaging app, but data that doesn't involve user interaction like fitness data or Core Location data. The exchanges need not be very frequent -- maybe once per minute or once every 5 minutes depending on battery status.


Another way to express the question is how to write an app that can periodially save data into a file on another phone via the cellular network, assuming the owners of the two phones are fully cooperative? (Or fetch data from another phone.)


Can someone suggest a general approach to such a thing? What iOS framework supports communication like this? I know (a little bit) about FireChat and iCloud but they don't seem to do what I want. I know how to build apps and I've written many so I'm not looking for coding help. I'm looking for a pointer to the relevant framework or documentation, or maybe a tutorial on how to do cellular data exchange.

Accepted Answer

For this to work over WWAN you have to use some sort of centralised server; doing this peer-to-peer over WWAN is virtually impossible.

Once you start thinking about centralised servers, you have two options:

  • build your own

  • use someone else's

The first option gives you more flexibility; the second gets you out of the business of running servers, which is generally a good thing.

Are both copies of the app being used by the same user? If so, you might able to do this using iCloud, either through the file system or via CloudKit. If not, you have to think seriously about security, because you want to make sure that the data doesn't get seen by people it shouldn't be seen by, faked, or otherwise corrupted in some malicious way.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
How can an app send data to another phone?
 
 
Q