What is a good solution to synchronize data between iOS apps? [closed]
Asked Answered
B

4

17

I am developing an application, whose data management is realized through Core Data, and I am studying how to implement a feature to synchronize data between two different devices (even between iDevices and Mac's eventually).

Until now I haven't found nothing interesting or useful, so I am asking you for a good start point, a guide, or a model to follow. Did you ever realize something like this?

Update

I've started a bounty on this question. Synchronization could be a difficult task on iOS, but come on, there's plenty of apps out there that offer device-to-device sync functionalities. My question is: how they do this? What's the best approach? What are the different solutions?

Update 2

This question is surely outdated, right now, since iCloud has been released almost a year ago. I'd like to keep it alive since it can give interesting insights on mobile data synchronization between devices.

Badger answered 27/5, 2011 at 19:44 Comment(7)
do you want an over-the-air solution, or is syncing while the iDevice is sync'd what you're looking for?Hedy
An over-the-air solution, if possible!Badger
is there an assumption of only two devices, or can there be three or more users/devices? can arbitrary data be modified by any device? when merge conflicts arrive, how will you resolve them?Hedy
I know that merging is a common problem when gathering data between distributes data bases. What I'd like to know is how others solve this problem. If it's just a question of brute force merging, that's not what I'd call "syncing".Badger
the merging problem is not a general solution, but needs to be done with your domain in consideration. Within Core Data, they handle disjoint edits and conflict resolution as defined here Core Data Programming Guide: Change Management - a common solution is "it fails", which is desirable and acceptable, because it means there were simultaneous duplicate edits - going "offline"/syncing later changes time scales = frequent failureHedy
What became of this? Did you find a solution, or did you implement your own? Looking into doing something similar, and trying to anticipate workfload and feasibility.Pewee
Probably the best way now is using iCloud. I did not find a suitable solution. All the roads seemed to be too hard to follow to me.Badger
N
11

If you want to do it yourself, this can be a very nice, yet challenging exercise. I don't know of any 3rd party frameworks that facilitate P2P connectivity between "iDevices", other than the ones below, from Apple. You can do some research along those lines if you don't want to re-invent the wheel. I am answering based on my (little) experience with implementing a syncing service via an app server - the principles must be more or less the same with a P2P approach.

The first step would be to design a protocol for syncing your data. Questions you might have to answer for yourself:

  • What do I need to understand about data synchronization?
  • Which part of my Core Data model do I want to sync? Should I make changes to my current model to facilitate syncing?
  • What serialization/deserialization mechanism will I use?
  • How will I be able to uniquely identify entities across multiple devices?
  • How will I version my data? How can I tell which entities need to be sync'ed?
  • Do I need to be able to revert a syncing operation?
  • How will I keep track of sync progress and how will I handle failures and exception cases? How will I notify the user of these?
  • Do I prefer to sync "incrementally" (parts of my model) or "globally" (the whole model at once)?
  • How often will the user need to sync between devices?
  • Are there any security considerations? Do I need encryption?
  • etc.

This is barely scratching the surface. You will definitely find more things to think about as you move forward.

Next, determine how you want to connect between devices. You seem to prefer an over-the-air solution, the P2P kind. For that, I would start by looking at these tools:

  • GameKit (this framework has APIs for establishing connectivity between devices over Bluetooth)
  • Bonjour (the Apple protocol for device discovery over a network - see the BonjourWeb sample application) + BSD sockets

Pick whichever tool(s) you feel most comfortable with and based on your design decisions discussed earlier. I can't help you there, as I don't have any experience with either of them. As Morpheus said:

I can only show you the door. You're the one that has to walk through it.

Sorry, little humor :)

Finally, decide on a solution to implement your syncing mechanism. You could e.g. choose a client-server model (one device will listen for a connection and another one will initiate it).

More relevant documentation:

I hope this gives you a starting path.

Narah answered 2/6, 2011 at 13:52 Comment(1)
This answer does not "solve" the question, but will be a good starting point for a good planning of synchronization techniques.Badger
E
3

Syncing data is notoriously tricky. Simplistic solutions are worse than no solution.

For good spiritual guidance on the matter, go check out what the authors of Things are doing with their upcoming cloud sync functionality. My hope is that they will release a syncing API through which developers can implement syncing services. But even if they keep it to themselves, they're demonstrating quite nicely the sort of soul-searching required to really rise to the task.

Electric answered 27/5, 2011 at 20:6 Comment(5)
Well, there are lots of apps out there that have a "sync between devices" feature. I just want to know how they do this. The authors of Things will probably find a better solution, but how do they do know?Badger
I think he was just warning you to expect a higher level of complexity than you might assume from all the buzz about "clouds". It's like date and time programming, looks simple at first glance but gets bizarrely complex in a hurry when you try to customize in the least.Outrank
I am expecting no particular level of complexity. I suppose that synchronization is a difficult task, even philosophically speaking :) I am not looking for a simple solution. I am looking for a solution.Badger
Btw, I do not want to sync "in the cloud" (for now). I just want to sync between devices. Later on I'll think about clouds, rains, and so on.Badger
apps with "sync'ing" between devices are usually either simple data transfer or brute force - there are a lot of questions that need to be asked and answered before you start toward a solution.Hedy
S
2

"Couchbase for iOS" might address your need

https://github.com/couchbaselabs/iOS-Couchbase

According to the readme:

Mobile Couchbase for iOS

Apache CouchDB on iOS provides a simple way to sync your application

data across devices and provide cloud backup of user data. Unlike other cloud solutions, the data is hosted on the device by Couchbase Mobile, so even when the network is down or slow (airplane, subway, backyard) the application is responsive to users.

What this means for you:

You can embed the rock solid distributed database, Mobile

Couchbase, on your iOS device. Your iOS apps can use Apache CouchDB's well-proven synchronization technology. If you <3 CouchApps, you can deploy them as iOS apps.

Subconscious answered 29/5, 2011 at 16:22 Comment(4)
Tris is clearly promising ... But I will have to migrate my existing Core Data database to this new one, and that's a bit scary ...Badger
The problem for Couchbase is that provides a method for synching data "in the cloud" and not a p2p approach for synching data between devices directly ...Badger
@Badger it's a distributed database, think git as a db. So it does not need to be device<->cloud, it is just as easy to device<->device. No it does not have automatic host discovery, but that can be setup in applicationBordello
URL is out of date (see repo description), new URL: github.com/couchbaselabs/iOS-Couchbase-manifestEmmen
O
-1

I would start with the Apple API Sync Services and see if that meets your needs. In principle, it would let you sync across all Apple devices and services.

Outrank answered 1/6, 2011 at 16:3 Comment(3)
Does this service enables synchronization between different devices directly? I mean, without using a computer or a cloud service in the middle.Badger
https://mcmap.net/q/746072/-sync-services-and-ios : Sync Services are not available on iOS devices ... so it's useless for me.Badger
And the rumor is that iSync and the services that underlie it are going away in Lion.Electric

© 2022 - 2024 — McMap. All rights reserved.