CloudKit how do I check for access level (public read, public write, private)

Hi,

I think the access status "available" means a private CloudKit db is accessible. While the reading of the public DB is always possible. But what about writing to the public DB. For this all I need is that the user is logged into iCloud, right? But how would I verify that?

All the best Christoph

Accepted Reply

to determine if a user is signed into iCloud, use CKContainer.accountStatus { … } https://developer.apple.com/documentation/cloudkit/ckcontainer/1399180-accountstatuswithcompletionhandl

Going further, record types in CloudKit can have various read and write permissions using security roles. CloudKit Security Roles are not well documented. See this thread for more https://stackoverflow.com/questions/31369181/how-do-the-cloudkit-security-roles-and-permissions-work

  • Hi,

    thank you for your response, but that kind of describes my problem, right? The account status tells me if I can store something in the private database of a CKContainer, but if I remember correctly from a WWDC video many years ago, the public database can written to if the user has a unique iCloud token which is given if the user is logged in, so even if the user disallows storing data in a private DB, right?

    All the best Christoph

  • Actually I was wrong the rights seem to have saved, when creating private data is turned off, you cannot create public any more either.

  • I finally found the apple reference and it's the video "Sync a Core Data store with CloudKit public database. Here Apple shows a sheet saying: Private Database = Required Account, Public Database = Optional Account. They do not say if optional even if writing, but I would assume so based on the context. (it's minute 7:44) so my question is still open.

Add a Comment

Replies

to determine if a user is signed into iCloud, use CKContainer.accountStatus { … } https://developer.apple.com/documentation/cloudkit/ckcontainer/1399180-accountstatuswithcompletionhandl

Going further, record types in CloudKit can have various read and write permissions using security roles. CloudKit Security Roles are not well documented. See this thread for more https://stackoverflow.com/questions/31369181/how-do-the-cloudkit-security-roles-and-permissions-work

  • Hi,

    thank you for your response, but that kind of describes my problem, right? The account status tells me if I can store something in the private database of a CKContainer, but if I remember correctly from a WWDC video many years ago, the public database can written to if the user has a unique iCloud token which is given if the user is logged in, so even if the user disallows storing data in a private DB, right?

    All the best Christoph

  • Actually I was wrong the rights seem to have saved, when creating private data is turned off, you cannot create public any more either.

  • I finally found the apple reference and it's the video "Sync a Core Data store with CloudKit public database. Here Apple shows a sheet saying: Private Database = Required Account, Public Database = Optional Account. They do not say if optional even if writing, but I would assume so based on the context. (it's minute 7:44) so my question is still open.

Add a Comment