CoreData database syncing without iCloud? - ios

With iCloud, you can sync your CoreData databases across multiple devices. This works by means of SQLite creating a transaction log that is replicated via the cloud. I like that mechanism, by I don't want to tie it to iCloud and Apple's servers.
Is there a way to enable this transaction log and manually replicate it using custom code and servers under my control?

No, at the moment the transaction logs are not exposed by any API. You can look at them on your Mac if you have iCloud enabled (they live in ~/Library/Mobile Documents/) to try to figure out how Apple is doing this and replicate it yourself. Sounds like a very difficult problem though.

Related

Is there a clean way to limit Realm Object Server sync to wifi connections only?

I am in the middle stages of an app development that uses Realm on the iOS handset and will synchronise data to ROS. The amount of data that it could generate could become quite large, so we would like to offer the user the choice of only synchronising when they have a wifi connection to protect their mobile data quotas.
I could achieve this by being careful about when the app logs on and off the server, but that is messy and will likely lead to errors.
Is there a clean way to set up the synchronisation engine to only perform syncs when the server url is accessible via a Wifi connection?
There is no way to limit sync on WiFi connection only, unfortunately. We have put it on our task list. https://github.com/realm/realm-mobile-platform/issues/143 It will be implemented in the near future.

CloudKit and Core sync data between devices

I created a simple Notes app based on Core data. Now i want add sync between user devices.
And all articles that i read (this, this) said that i should fully get rid of my core data database, and all my code will lost and rework all with ICloud kit?
The is no way to sync data from Core Data to ICloud ? And if i get rid of core data, how my app will work offline ?
And please suggest good simple projects with ICloud sync
P.S. I googled about an hour. Icloud is deprecated so do sync with it is not recommended. I confused. How now i can sync data between devices??
Core Data used to have iCloud syncing, but it has been deprecated as of iOS 10. It had several problems, sometimes major.
Apple now has something called CloudKit, which is not the same thing. You can use CloudKit to sync data between devices. But this does not mean that you should drop Core Data. CloudKit only syncs; it is not a replacement for having your app save data on the device, it's only a way to send data to other devices. If you're using CloudKit, you also need to use some other way to store data on the local device.
Also, it's "CloudKit". Not "ICloud Kit". I don't know why, but it's important to get the names right.

Real time syncing

I want to develop application same as UBER in which I need to show available taxis in the selected region and update as the taxis are hired, available, unavailable. Kind of auto refresh.
Calling the web service in the background after regular time interval is not a good option.
Can any one suggest me better and fast way to achieve this.
Thanks
Push
Use sockets when the app is running. This will give you immediate updates.
Use Push notifications when the app is not running (use notifications for critical changes), and ignore these notifications when the app is already running, in favor of sockets.
Pull
Use NSURLSession to refresh your local DB with some regularity. This is very resilient to network failure.
Use a combination of approaches, since speed and robustness are mutually exclusive. Ultimately, your objective is to keep your local DB in sync with your server's DB, and fire internal messages as data changes. No small task, hence the Firebase answer.
The Most Simple way is to work with Firebase . Its No sql database and you will have instant update as you change anything .
This Video will guide you how speedy you can get update without any loop for refreshing data in application .
Ask me any help you need regarding Firebase .
You can use silent push notifications to update your map with updated taxi locations.
I would suggest you take a look at CloudKit. There are several reasons.
If you decide to just build one app and somehow have driver
functionality that is different from users (maybe by having drivers
register and sign-in) then the app can post shared data to a public
online database accessible to all users. You could use information
in this scenario to post local notifications as the need arises.
As iOS updates you will not be dependent on third party libraries
If you decide to create a driver app and a separate user app,
CloudKit will allow you to share data across these apps.
Apple deals with the security and availability.
Overall the process is very easy to implement.
You can combine the local notifications with the public database to
schedule reminders, alert users etc.
CloudKit when done correctly will be essentially free. Just transfer
CKAssets rather than raw data and your transfer/storage limits
become negligible.
You can also access your CloudKit databases from external web
services/websites if you want to extend the data further.
You can use CloudKit subscriptions to sync up user information
automatically
NB - As pointed out in comments this is new technology. It is in the
second generation and I prefer it because if one uses it creatively
then you can simulate the external push notification behavior together
with background support. CloudKit removes the need for a third party web server from which to push the external notifications (as the real notifications take place by writing to the shared database).
Check out my detailed answer on SO for sharing the data between apps with CloudKit. Here is a link to some CloudKit videos that further describe how CloudKit works. Apple has lots of documentation and sample projects available. You can review the developer website for more info on CloudKit.
CloudKit Quick Start

Using iCloud for core data sync

Mine is a background application. There are thousands of data that are stored in local storage and till now i've been syncing the data to a remote server using http post. I want to know whether it is possible for me to use iCloud to sync my core data and then is it possible to sync from iClod to a remote server. I just want to use iCloud for storage purpose. I meant can it be operated like Parse and other third party cloud servers. I'm stuck with this. Any help would be greatly appreciated.
The only thing iCloud with Core Data does for you is sync data between multiple devices that use the same iCloud account.
I want to know whether it is possible for me to use iCloud to sync my core data...
Sync from one device to another, yes.
...and then is it possible to sync from iClod to a remote server.
If you're using Core Data with iCloud, you're still using Core Data, so any server sync you're doing now with Core Data will continue to work in the same way.
I just want to use iCloud for storage purpose.
It does store the user's data on the iCloud service, though it can only be accessed through your app.
I meant can it be operated like Parse and other third party cloud servers.
It depends on what Parse (or other third party) services you're interested in. Parse does more than iCloud, it's not really the same thing. If you would use Parse only to sync data between different devices, you could probably use iCloud. If you would use Parse in any other way at all, iCloud is not a replacement.

Storage for iOS development

I have db which is kept in Core Data and I need to download full data from some storage. I don't want to write web server for this. Is there any way to store my full data for further downloading? Can I use iCloud for this? Or anything else? Thank you
iCloud is connected to you personal Apple ID, so it would not be possible (or at least not its intended use) to allow others to download data from your iCloud account.
Have a look at Parse or Azure. One of them might be the solution you are looking for.

Resources