CloudKit JS and Web services
Related Sessions : Introducing CloudKit (WWDC 2014) and Avanced CloudKit (WWDC 2014)
- JSON/HTTPS interface to CloudKit
- Web sign in with Apple ID
- JS Library
- Support browsers : Chrome, Safari, Firefox, IE , Microsoft Edge
CloudKit Architecture
- Public Database
- Default zone for CRUD records
- Private Database
- Default zone for CRUD records
- Custom zone for CRUD records
Features parity as native
- public/private database accesss
- CRUD
- Asset
- Query
- Subscription and notifications
- User discoverability (getting users' full name)
- Sync
- authertication
All adove features works in JSON API
Completions block is adopted as JS promises
similar class ,methods names and calling to native counterparts.
Getting Started
- create a container
- create a schema
- container can be created from either portal or xcode
- schema can be created from CloudKit web dashboard or on-demend by the app
Enable web access
- generate web service api token with cloudkit dashboard
- set login callback
- set domain restrictions
Lots of code sample in js to use Cloudkit
Best Practices with CloudKit JS
- Dynamically link to the CDN-hosted Vesion for latest release of CloudKit JS
- Consider loading CloudKit JS asynchronously on your page
- Handle request throttling responses (i.e. in order not to go over request/second limit, handle burst request gracefully.)