I have the same question. I'm writing an app that depends on these.
I've looked at CKFetchDatabaseChangesOperation and CKFetchRecordZoneChangesOperation thinking that perhaps in iOS11 these now support the public database. But they don't.
I don't see how we are supposed to get a list of notifications/changes from the public database without these methods.
I'm kind of at a standstill until I figure this out, since if these really are going away, I'll need to rethink a major part of my (already implemented) CloudKit logic. I don't want to carry on with other parts of the app knowing I may have to rip a bunch of stuff out!
Does anyone have any suggestions?
I have no idea why this functionality was removed for the public database.
My solution is to maintain a local change token based on date.
When my app launches, I perform a query operation on the public database with predicate modificationDate>lastUpdateDate, with lastUodateDate obtained from UserDefaults, to obtain all the records which have changed since the app was last launched. If lastUpdateDate is nil (i.e. never set), I set the predicate to true to fetch all records. When query operation completes without error, I set lastUpdateDate to current date and save in UserDefaults.
If you use a subscription to track changes to the public database, you can update the lastUpdateDate on notification to stay current.
It is a bit inconvenient, but does not require much additional code.
I would be happy to post some code if desired.
It would be great:
- to see a code sample. Do you map the notification to a particular subscription in order to query records of a particular type?
- to figure out where you got more information about this. Apple's deprecation message is not applicable for the pubilc DB. I can't find details or suggestions other than what you've posted.
- to understand why we don't have to mark notifications as read. This seems to be a mystery still.
From iOS 11 headers.txt:
CloudKit/CKMarkNotificationsReadOperation.h:14: API_DEPRECATED("Instead of iterating notifications, consider using CKDatabaseSubscription, CKFetchDatabaseChangesOperation, and CKFetchRecordZoneChangesOperation as appropriate", macos(10.10, 10.13), ios(8.0, 11.0), tvos(9.0, 11.0), watchos(3.0, 4.0))
CloudKit/CKFetchNotificationChangesOperation.h:13: API_DEPRECATED("Instead of iterating notifications to enumerate changed record zones, use CKDatabaseSubscription, CKFetchDatabaseChangesOperation, and CKFetchRecordZoneChangesOperation", macos(10.10, 10.13), ios(8.0, 11.0), tvos(9.0, 11.0), watchos(3.0, 4.0))
I saw those notices as well. As mentioned above, those do not work on the public database, so they don't replace the deprecated methods as a way to get changes from the public database. They *are* a great way to get changes for the private and shared database, however.
Me too. rdar://33787818
Did anyone figure this out? Has Apple responded to any of your radars?
Does this deprecation apply only to notifications on a public database, but we can continue to use it on a private database? Or is it no longer available for anything?
I'm stuck with this as well.
I'm using a CKQuerySubscription with a NSPredicate and now in iOS 11, it prompts me with this deprecated notice, and I cannot find a way to fetch pending notifications and mark them as read.
This is such a bummer in my workflow right now, I'm completely stuck.
CKQuerySubscription is not deprecated 100%. But its scope is changed
For Public Database default zone & Private Database Default zone use CKQuerySubscription for getting notification.
There is 2 Step process for Shared Database & Private Database Custom Zone.
Step 1: CKDatabaseSubscription to Private & Shared Database.
first step will get you zone add, zone update or zone delete notifications to private & shared database.
Step 2: Fetch all the custom zones from shared database & Private database. And create CKRecordZoneSubscription for every zone.
Note: CKQuerySubscription does not work for Shared Database but it will work for Private database custom zone where you can add predicate & notification options.
Because we created CKDatabaseSubscription in step 1. If there are any addition or changes or deletion of zone while we are fetching custom zones from Private & Shared database. You will get notification.
If notification type is .database then based on subscription ID fetch all zones from shared or private database.
If notification type is .recordZone then get zone ID and fetch record changes using previously saved server change token.