Cannot accept CKShare invitation

Hi, after sharing a NSManagedObject, I send the link that CloudKit creates on open it a different device. The function func windowScene(_ windowScene: UIWindowScene, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) is called but when I accept the invitation, CloudKit returns this error:

userDidAcceptCloudKitShare(with:): Failed to accept share invitations: Error Domain=NSCocoaErrorDomain Code=134406 "Request 'A8FAB7C2-CF35-44E0-A0B9-C359757C248F' was aborted because the mirroring delegate never successfully initialized due to error: <CKError 0x6000023083f0: "Partial Failure" (2/1011); "Couldn't fetch some items when fetching changes"; uuid = 91B8D4ED-5A71-4786-978E-2977020A4468; container ID = "iCloud.com.francesco"; partial errors: {
	com.apple.coredata.cloudkit.share.561FDA24-2AF9-4536-A443-A3EE54746773:__defaultOwner__ = <CKError 0x600002337f00: "Invalid Arguments" (12/2006); server message = "Only shared zones can be accessed in the shared DB"; op = 8FB6A2BF8FF71552; uuid = 91B8D4ED-5A71-4786-978E-2977020A4468>
}>" UserInfo={NSLocalizedFailureReason=Request 'A8FAB7C2-CF35-44E0-A0B9-C359757C248F' was aborted because the mirroring delegate never successfully initialized due to error: <CKError 0x6000023083f0: "Partial Failure" (2/1011); "Couldn't fetch some items when fetching changes"; uuid = 91B8D4ED-5A71-4786-978E-2977020A4468; container ID = "iCloud.com.francesco"; partial errors: {
	com.apple.coredata.cloudkit.share.561FDA24-2AF9-4536-A443-A3EE54746773:__defaultOwner__ = <CKError 0x600002337f00: "Invalid Arguments" (12/2006); server message = "Only shared zones can be accessed in the shared DB"; op = 8FB6A2BF8FF71552; uuid = 91B8D4ED-5A71-4786-978E-2977020A4468>
}>}

Code I use to share the object:

UICloudSharingController {
  self.container.share([unsharedFolder], to: nil) { (objectIDs, share, container, error) in
      guard error == nil, let share else {
        Logger.iCloudShare("\(#function): Failed to share an object: \(error!))")
        completion(share, container, error)
        return
      }
      
      if existingShare == nil {
           share[CKShare.SystemFieldKey.title] = unsharedFolders.first?.name ?? "Folder"
      }
      
        completion(share, container, error)
    }
}

Code I use to accept the share:

self(from: [cloudKitShareMetadata], into: self.sharedPersistentStore) { (_, error) in
      if let error = error {
        Logger.iCloudShare("\(#function): Failed to accept share invitations: \(error)")
        return
      }
      
      Logger.iCloudShare("CloudKit Share with metadata accepted: \(cloudKitShareMetadata)")
    }
  }

Any idea why this happens? If any other code is needed I will post it.

I see these errors after a successful initial share. I can share one record just fine. Any subsequent shares of other records produces these same messages.

Have you been able to overcome this @francescoleoni?

Cannot accept CKShare invitation
 
 
Q