ios – Can I use CloudKit on Android or web-based app?-ThrowExceptions

Exception or error:

I’ve been coding an app, and using CloudKit would make my life a lot easier. However, this app needs a web-base app along side the iOS app. I was wondering if there was any way I could use CloudKit with Android or web-based apps.

While this might not directly possible with an API provided by Apple, another possibility would be to use OS X Server for CloudKit. Would that be possible too/comply with Apple’s Terms of Service for CloudKit?

How to solve:

Yes you can. Apple provides CloudKit JS, specifically designed for web services. I don’t know much about Android, but I’m pretty sure it’ll be not a hard challenge to run JavaScript.

Also CloudKit WebServices could be interesting for you.

EDIT advice and discussion

To give you an honest advice: Better use something “own”. I currently work with a custom server on an AWS EC2 instance and am really happy.

You could, for example, write a really simple server using Node.js and connect a Mongo DB NoSQL database. CloudKit is actually not more than this.

This is really a simple task. I did this before and with some JavaScript experience and a few days Node exercises it is absolutely feasible; you’ll write really nice servers very quickly.

In the end, when dealing with more customers, CloudKit will be more expensive, actually. And if you, why ever, must move to a different service, you will have trouble with CK, because you are not able to access the privately stored data.

Also, be sure that CKs concept fits your needs. I was in your situation a few months ago. As I read more about CloudKit and viewed some WWDC sessions, I more and more realised that it is not a BAAS as you would probably expect.

One example: You have no access control: private or public, thats it. There is a public database which everyone can access each resource in. And a private one for any user, which is inaccessible by others.

If you don’t want to, or can’t, do something on your own, you could simply use BAASBOX for self-hosted APIs or just any commercial BAAS.


EDIT II

To point that out again for anyone late in the game:

The private (per-user) databases are absolutely inaccessible for others – even you as the developer and operator can’t access the, most probably encrypted, data to move to a different (maybe self-hosted) service.

You’d need to make an update and the app then needs to move the data to your new service on the users behalf – “device-ly”.

These kind of processes are typically problematic because you’d need to run two services until all active users moved their data – which is REALLY hard to tell; your customer might be idle for some time and they’d be upset if their data is lost in void forever.

Ok – Cloudkit might continue until… Yeah, until then. So it might not be as problematic to do that kind of passive longterm-movement.

###

Unfortunately CloudKit is only available for the Apple ecosystem. However, there are similar technologies called Parse and FireBase that allows you to do the same, but can be cross platform. However, they cost a lot more and are not client-side services.

NOTE – Parse’s hosted services will be fully retired on January 28, 2017.

###

Use CloudKit JS to build a web interface that lets users access the same public and private databases as your CloudKit app running on iOS or macOS.

You must have an existing CloudKit app and enable web services to use
CloudKit JS.

for Set up your app’s containers and configure CloudKit JS do following step by step:

  1. Create your app’s containers and schema.

    If you are new to CloudKit, start by reading CloudKit Quick Start. You’ll use Xcode to create your app’s containers and use CloudKit Dashboard to view the containers. Then create an iOS or Mac app that uses CloudKit to store your app’s data.

  2. In CloudKit Dashboard, enable web services by creating either an API token or server-to-server key.

  3. Embed CloudKit JS in your webpage.

    Embed CloudKit JS in your webpage using the script tag and link to Apple’s hosted version of CloudKit JS at https://cdn.apple-cloudkit.com/ck/2/cloudkit.js.

    <script src="https://cdn.apple-cloudkit.com/ck/2/cloudkit.js">

The CloudKit JS version number is in the URL. For example, 2 specifies CloudKit JS 2.0.

  1. Enable JavaScript strict mode.

    To enable strict mode for an entire script, put “use strict” before any other statements.

    "use strict";

  2. Configure CloudKit JS.

    Use the CloudKit.configure method to provide information about your app’s containers to CloudKit JS. Also, specify whether to use the development or production environment. See CloudKit for an example, and see CloudKit JS Data Types for details on the CloudKit.CloudKitConfig properties you can set.

Now you can use the CloudKit.getDefaultContainer method in your JavaScript code to get the app container (CloudKit.Container) and its database objects (CloudKit.Database).

ref lineks:

Cloud kit quick Start

Accessing CloudKit Using an API Token

CloudKit Web Services Reference

Accessing CloudKit Using a Server-to-Server Key

CloudKit Catalog: An Introduction to CloudKit (Cocoa and JavaScript)

iCloud Design Guide

Ref Page:

CloudKit JS

Leave a Reply

Your email address will not be published. Required fields are marked *