I'm trying to save a CKQuerySubscription
to the public database - a CKError
is returned with the following information:
[
"ServerErrorDescription": subscription is duplicate of 'C82E82EF-F373-4D75-A465-65364D8FEB12',
"CKErrorDescription": Error saving record subscription with id E30DB4D5-2617-4E0D-8CFE-A14538140029 to server: subscription is duplicate of 'C82E82EF-F373-4D75-A465-65364D8FEB12',
"NSDebugDescription": CKInternalErrorDomain: 2032,
"NSUnderlyingError": <CKError 0x1c064ec70: "Server Rejected Request" (2032); server message = "subscription is duplicate of 'C82E82EF-F373-4D75-A465-65364D8FEB12'"; uuid = A5290A31-650C-44FC-B1C1-7BCB181291F8; container ID = "iCloud.com.mycompany.myapp">,
"NSLocalizedDescription": Error saving record subscription with id E30DB4D5-2617-4E0D-8CFE-A14538140029 to server: subscription is duplicate of 'C82E82EF-F373-4D75-A465-65364D8FEB12', "errorKey": ck1uc5yob,
"RequestUUID": A5290A31-650C-44FC-B1C1-7BCB181291F8,
"ContainerID": iCloud.com.mycompany.myapp
]
The properties ancestorRecord
, clientRecord
and serverRecord
on the CKError
object are all nil
.
How can I get the ID of the query that exists on the server from this error (ie C82E82EF-F373-4D75-A465-65364D8FEB12
). Is there a property that I'm missing that would have it?
There are a couple of options. I tend to use
fetchAllSubscriptionsWithCompletion
handler to pull all subscriptions and then parse the ones I'm interested in, like so:But you can also use CKFetchSubscriptionsOperation to pull all subs, or specific subs based on the subscription ID. In this case, you'd create the operation, configure the subscription ID you're interested, add your post-processing code to the completion block, and then run then run the operation.