Video available on “The dot Post” website:
My aim for this talk was to bring back, to the developers attention, a particular SDK which seems to float in obscurity at the moment.
Apple has been providing cloud services for a while… and it’s fair to say they had their problems.
But I believe the tide has changed in 2014 when at WWDC they announced CloudKit, a framework that allows developers to store user data inside Apple servers.
It works by giving apps access to containers, private to your developer account. An app can access more than one container. That also means that containers can be shared between your apps.
A container encapsulates a public and a private databases. In fact a private database is being created for each user, and a particular user only has access to the public database and her own private database.
Each database (either public or private) is divided into zones and there is a default zone. One can create as many as required. Zones in where we store records and they are the entities that provide atomicity.
It is not cool to mix records if they belong to different zones. Also you cannot reference records across zones.
CloudKit APIs are pretty simple: you get a container, a link to a database. And convenience APIs that provides asynchronous CRUD on records. There is also a lower lever set of APIs based on NSOperation.
One quick tip: create a dedicated developer test account which you can use to login into iCloud on the simulator; this way you’ll be able to validate any private data using the CloudKit Dashboard.
I encourage you to check the sample project that Apple provides; it’s quite clever — it allows you to run the sample code right in your browser.
One thing to notice: because we’re using iCloud authentication, you automagically “get” the two-step verification on login.
Advantages & Disadvantages
So these are the reasons I believe developers should use CloudKit:
- Easy of integration
- Security & Privacy
- Free authentication
- [Partial] Ubiquity
But the most importantly is peace of mind — you probably saw Parse announcement regarding cease of business; nothing is really free.
And I have 2 things on my wishlist:
- Complete ubiquity
- Server-side scripting
New Business model
One last thing: going back to container model, you as developer are responsible for the hosting costs for the Public database and each user is responsible for the storage space used by their private database.
In a standard app that charge a fee upfront — the customer lifetime value decreases with the usage.
But using CloudKit will not — and can lead to new business models.
Update - Feb 7th 2016:
Looks like Apple already granted one of my wishes :) — “CloudKit Now Supports Server-to-Server Web Service Requests”: