Seed and maintain CloudKit public database without requiring iCloud login?
Asked Answered
O

1

1

The Apple docs say reads from an app's CloudKit public database can occur without an iCloud login, but writes cannot. Saving or updating records to the public database require an iCloud login.

What if you want to seed and maintain the public database as an administrator? For instance, for a map app, if you as an administrator want to populate and maintain the public database with demographic data for each country, does your flow still require an iCloud login?

If posting code snippets, Swift is preferred. Thanks.

Odette answered 23/4, 2016 at 8:44 Comment(3)
Your answer is in your question: "Saving or updating records to the public database require an iCloud login".Scribbler
@Scribbler understood, but other posts (like the answer below) have alluded to the ability to make public writes anonymously. but you have answered many other questions on swift and ios, so thanks for those contributions!Odette
@Scribbler it seems like you can allow public writes as an administrator (and not require icloud authentication) via a server-to-server key? developer.apple.com/library/ios/documentation/DataManagement/…Odette
H
2

The answer to your question is on the cloud dashboard.

CloudKit dashboard snapshot showing permissions

This is the permissions for public database your looking at, you can make it writable as I have here for an authenticated account, so somebody logged in with their iCloud account, but there is no option to make it writable anonymously.

But I can see the confusion here, the database belongs to the app, not the user and you can make the public part writable by anybody as I have here. So in your example your maps app it would write to its public database so that other users would have access to it.

The caveat you need take care of here is the fact that the quota for the public database goes with the app's owner, you. So you don't want to put too much data there or indeed give even authenticated users the ability to upload heavy objects, cause if you do you may come unstuck with the finances. You have a quota, which gets bigger the more users you bring on board, but how that works out in the real world is a challenge to manage.

Hymenopterous answered 23/4, 2016 at 17:42 Comment(6)
thanks! what exactly are the steps to make the public database writeable by anyone?Odette
and by anyone, you seem to mean anyone who is authenticated, not someone who hasn't logged in via icloud (which is what the question focuses on).Odette
You do not have the option to make the writable by anyone, and as I explained even if you did given you end up paying the bill it would be highly undesirable.Hymenopterous
it seems like you can allow public writes as an administrator (and not require icloud authentication) via a server-to-server key? developer.apple.com/library/ios/documentation/DataManagement/…Odette
I just read over this; and it seems true. But it needs to be said again, the costs of writing to the public database fall to the developer if the quota is exceeded. You can it seems use this mechanism to spare you using your or indeed asking for iCloud authentication. But beware, if you write too much data you'll be paying the bill, so don't whatever you do give this capability to the user or your app.Hymenopterous
yes, but all writes to icloud -- public or private -- happen through your code so you can guard against this scenario. it's not like users can magically write to the public database (unless they steal your key) without your cooperation.Odette

© 2022 - 2024 — McMap. All rights reserved.