Kodeco Forums

CloudKit JS Tutorial for iOS

iCloud does a lot of great things. It bridges the gap between iOS and macOS by storing and syncing app data and files so the user can access their stuff from any Apple device. Notes and Photos are excellent examples of the power of this service — if your stuff’s on one device, it’s reliably […]


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/997-cloudkit-js-tutorial-for-ios

Hi Audrey,

I have a question - in your app’s OAuth window, the container ID is visible.

However, it appears it is possible to change this to a custom name / title.

Do you have ideas on how this can be done?

Thanks!

You’ve probably seen 1Password’s blog post Blog | 1Password

I looked at their AgileCloudSDK repo, and this is the most likely thing I found: CloudContainerNameKey in AgileCloudSDK/CKContainer.m at master · agilebits/AgileCloudSDK · GitHub

I tried changing the name of the CloudKit container in my developer account Certificates, IDs & Profiles, but it has no effect on the sign-in window.

Nor could I find anything helpful in the CloudKit Catalog source code CloudKit Catalog: An Introduction to CloudKit (Cocoa and JavaScript)

On the CloudKit.configure documentation page, there’s a tantalizing sentence: To customize the sign in and sign out buttons, add signInButton and signOutButton keys to the auth dictionary. But I couldn’t find anything more about this.
https://developer.apple.com/reference/cloudkitjs/cloudkit/1628513-configure

Your best bet might be to contact support+agilecloudsdk@agilebits.com

good luck!

Hello Audrey,

That’s a very good tutorial, thank you very much!

I have a question. Is it possible to use the cloud kit server-side API to backend android apps? Does it work well?

Thanks once again!

very good question! but I suspect it wouldn’t work, because you’d have to include your private key in every installation of the android app.

Thanks for the example. I’ve been trying to get an Android app working that basically contains the same capabilities that this web app has. I’ve created a WebView and loaded an HTML file the includes the cloud kit JS api, my javascript file with code from this example and places for the sign-in and sign-out buttons buttons to go. I am able to fetch the data from the public database and display it in a TextView. The javascript code you provide in the example works fine for me except when I run the setUpAuth method. It causes the Apple sign in button to appear in my app. However, when I press this button a new instance of Chrome mobile opens with the Apple sign in page. Then when I go to sign-in with my Apple ID the page goes to sign-in and just hangs indefinitely. Because of this, I can’t gain the authentication needed to make any changes to the public container from my app. Is Apple blocking sign-in requests from mobile browsers? Is there some workaround I can use, maybe another way to get a user authenticated so can make changes to a public container? Or is authentication from an Android app using CloudKit JS just not possible yet? Thanks Greg

Apple seems to have made it harder to sign into iCloud from non-safari browsers, since 2013 or so. I found this forum thread:

Scroll to the bottom of page 2 for some 2016 answers. Although some answers indicate there might not be a solution that works for all models.

I discovered recently that the WWDC videos won’t play on any non-safari browser!

Hello Audrey,

Is it possible to have a web app to use CloudKit without an iOS/macOS app?

hi Sarath

certainly! but if you just want a back-end server, look at Ray’s Vapor screencasts – they’re in chronological order, starting from Oct 18 Getting Started

Ray uses the TIL app, so you can compare with this CloudKit JS version.

And they’re all free!!

CloudKit has the potential downside that you can’t access your users’ identities unless they opt in. Some devs have told me some apps like/need to have this info, so rolling your own back-end would give you more control over authentication etc.

But how the containers will be created without iOS/macOS app?

The tutorial sets up the CloudKit database via the app, to show how CloudKit sets up record types automagically when you save the first record.

But you can do all the set up directly in the CloudKit dashboard, then use its container ID in the .js file

Thanks for the quick response.
So here is what I understood, I need to create an app id in the developer portal for which cloudkit is enabled and manager it from the dashboard.

from Certificates, Identifiers, Profiles, you can list and create iCloud containers, or you could create an empty app in Xcode, and turn on CloudKit capability, then Xcode will create the container for you, and a button for you to open it in the dashboard.

Hey @audrey,

I can’t seem to get passed the “Your account does not have sufficient permissions to modify containers” message. this is regarding the “Cloud Kit Tutorial” Is there anyway to get around this? I am an Apple Developer but couldn’t find any helpful information.

can you login to the CloudKit Dashboard?

Or, if you create a new project with your team, do you see this in the Capabilities tab?

You must be in the paid developer program to use CloudKit. If you’re using your paid dev account, and cannot access CloudKit, then contact Apple to see if they can fix your account.

1 Like

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]