I cannot get any zones from fetchAllRecordZones

I create a share and the shared URL is successfully created

           
Code Block
 let share = CKShare(rootRecord: infraRecord)
            // save
            let op: CKFetchShareParticipantsOperation = CKFetchShareParticipantsOperation(userIdentityLookupInfos: lookupInfos)
            op.fetchShareParticipantsCompletionBlock = { error in
              if let error = error {
                print("error: ", error)
                completion(false, error)
              }
            }
            op.shareParticipantFetchedBlock = { participant in
              participant.permission = .readOnly
              share.addParticipant(participant)
              let modOp: CKModifyRecordsOperation = CKModifyRecordsOperation(recordsToSave: [infraRecord, share], recordIDsToDelete: nil)
              modOp.savePolicy = .ifServerRecordUnchanged
              modOp.perRecordCompletionBlock = {record, error in
                print("record completion \(record) and \(String(describing: error))")
              }
              modOp.modifyRecordsCompletionBlock = {records, recordIDs, error in
                if let error = error {
                  print("error in modifying the records: ", error)
                }
                else if let anURL = share.url {
                  // update the location CKRecord with share URL
                  self.updateLocationPublicRecord(withShareUrl: anURL.absoluteString, locationRecord: locationRecord, completion: { (status, error) in
                    if let error = error {
                      print("error: ", error)
                    }
                  })
                   
                  print("share url \(String(describing: share.url))")
                }
                completion(true, nil)
              }
              self.privateDB?.add(modOp)
              //completion(true, nil)
            }
             
            self.defaultContainer?.add(op)


To access the share I first try to get the recordzones from shared database

 
Code Block
 func getRecordZones(completion: @escaping (CKRecordZoneID?, Error?) -> Void) {
    self.sharedDB?.fetchAllRecordZones(completionHandler: { (ckrecordZones, error) in
      guard error == nil else {
        if let ckError = error as? CKError {
          self.aErrorHandler.handleCkError(ckerror: ckError)
        }
        completion (nil, error)
        return
      }
      if let recordZones = ckrecordZones {
        for i in 0 ..< recordZones.count{
          // find the zone you want to query
          if recordZones[i].zoneID.zoneName == Cloud.SharedZone.UserProfile.ZoneName {
            completion (recordZones[i].zoneID, nil)
          }
        }
      }
    })
  }

```
I dont get any recordzones from shared database. When I go to cloudkit dashboard, I don't see any shared zones in the shared database. Why is it that shared record zone does not exist? how to make this work?

Replies

Edits: I see in the cloudkit dashboard there is shared database zone with zone name: userProfileZone and owner name _9d4825db9b0aa911655e420ec0016129. But the below code after fetching CKRecordZone from shared database returns nil
Code Block
self.sharedDB?.fetchAllRecordZones(completionHandler: { (ckrecordZones, error) in
if error != nil {print(ckrecordZones?.first?.zoneID.zoneName)}
}

I dont know why it is not returning the zone
Also in cloudkit dashboard if I fetch zones in shared database then it return nil. But when I fetch with Fetch with change token box checked and field empty then it returns the above userProfileZone. But the details are grayed out. I dont understand what is going on. I would appreciate any help