Question

I need to build a simple interface between 2 instances of the same app running on 2 different iPads, which can communicate between themselves.

The idea is to create a permanent link between them (by exchanging some kind of Id), that would be possible to keep (possible by storing the Id) even after one or both the iPads reboot, without the need of user intervention.

For the sake of context, that interface could be used, for instance, on a shared grocery list app, or on a 1-to-1 turn base game.

The Apps would not need to be nearby, nor both would need to be active when data is sent (the receiver could be turned off when data is sent, and receive it later)

I imagine that, if this is possible, it would need to be done using gamekit. Can this be done? If so, how?

Thank you

Was it helpful?

Solution

There are so many ways to do this. But in general:

Database: you'll want a server side database to store the common data. The most common options for this are i) host your own database server and create REST API endpoints to access the datastore, ii) use on of the many Platform as a Service (PaaS) companies out there (Parse, Stackmob, Azure, etc). Generally, the PaaS provide a cheaper faster way to get up and running and you'd probably only want your own server if the app was fairly complex. You could always start PaaS and transition to proprietary later if needed.

Synchronization: To communicate between the devices your options are i) client side polling (ie. check for updates to the database every n secs/mins), or ii) push notifications from the server when a record is inserted/updated). For push, you'll want to avoid using APNS (Apple Push Notification Service) as message delivery is not guaranteed (users can decline to receive push notifications) and you'll want to either create your own sockets connection or use a push service like Pusher or PubNub which provide reliable message delivery from server to client. You'll only want to implement APNS for when the app is closed (to notify the user of new activity). When the app is open, use one of the more reliable methods listed above.

That's the general methodology.

EDIT: To be clear, there is no reliable way to do this without using a) a server to store the messages/state, b) a third party service like Pusher or PubNub to reliably deliver the messages between devices, whether the other device is active or not (and really you are then just using their server instead of your own). You could skip using your own server/database and simply send messages back and forth with a reliable service and have them each maintain state locally and synchronize. But note, APNS is not a reliable message delivery service for maintaining synchronization like this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top