Records, Zone Doesn't Displayed in Dashboard and Delete Zone Issue Cloudkit

When is recordZoneWithIDWasPurgedBlock and recordZoneWithIDWasDeletedBlock called?

A bug of my own doing caused the custom zone to always be created at app launch which would obviously never trigger delete blocks AND invalidate all change tokens.

I have the most frustrating type of advice for those having a similar issue: check your code! Make sure you're not creating the custom zone before you fetch database changes.

Cloudkit: ZoneId provided doesn't match target zone

you have to set the zoneID on the operation wit something like:

    operation.zoneID = CKRecordZoneID(zoneName: sharedStore.checksID!, ownerName: "your name")

Update: As discussed below the .zoneID is only available on a CKQqueryOperation and not a CKModifyRecordsOperation

I believe it's only possible to set a CKReference to a record that is in the same zone. Is that the case? If not, then could you try saving the record without that reference?

From the documentation:

Treat each custom zone as a single unit of data that is separate from
every other zone in the database. Inside the zone, you add records as
you would anywhere else. You can also create links between the records
inside a zone by using the CKReference class. However, the CKReference
class does not support cross-zone linking, so each reference object
must point to a record in the same zone as the current record

update:
it is possible to add a reference across databases (public and private) provided the source and target of the reference are in the default zone.

How to fetch records from a specific record zone

You could use a CKQueryOperation and set the zoneID like this:

    let operation = CKQueryOperation(query: query)
operation.zoneID = CKRecordZoneID(zoneName: "name", ownerName: "me")

I'm receiving an Error while trying to delete records from CloudKit Public DataBase

Sign in to the CloudKit Dashboard and review the security rules you have set. Select your CloudKit container (that has your public database in it) in the left nav.

Here are is what you can check:

  1. Container Permissions - Does the Apple ID you are using on your Mac have permission to access that container?
  2. Security Roles - Click any link to go into your container (like Data). Then click the large, bold text in the upper left (probably set to "Record Types" right now) and select Security Roles. Does your role type have permission to Write to the record type you are trying to edit?
  3. iOS Simulator - One common mistake it to not be signed into an iCloud account in the iOS simulator. Be sure to go into the Simulator's Settings and sign in.

Purge/Clean all user iCloud records for CloudKit container

If you are using the private database with "no zone", you are really using the default zone. In order to delete all data from the default zone you need to query every record id for every record type and perform a deletion of every result. This is very inefficient.

I suggest that instead of using the default zone in the user's private database, you create and use a custom zone in the user's private database. Then if you ever need to remove all data for the user, simply delete the zone. One call, simple and efficient.



Related Topics



Leave a reply



Submit