I am new to subscriptions and Cloudkit and I am trying to setup subscriptions to send a push notification whenever CKShare records are created, edited, deleted, as well as when a participant leaves the share for both the private and shared database.
In my application I have two record types in Cloudkit. The first is Deck and second is Card. Deck has a one-to-manyrelationship with Card. Each Card holds a CKReference to its Deck. I have noticed in the Cloudkit dashboard there is a third record type named cloudkit.share. From my research I believe I will need four subscriptions here. One each for Deck and Card on the private database using a CKQuerySubscription and one each for Deck and Card on the shared database when the user accepts a share using a CKDatabaseSubscription. Will I also need to create another subscription on each database for the record type cloudkit.share as well, totaling six subscriptions?
Thank you
After setting up a single
CKDatabaseSubscriptionon the both the shared and private databases, any changes will trigger the AppDelegate method:The shared database is a little more complicated as you can’t query the default zone. You’ll need to set up an initial
CKFetchDatabaseChangesOperationusingsetRecordZoneWithIDChangedBlock:^(CKRecordZoneID * _Nonnull zoneID)to get the shared record zoneID. With this you can query all shared records in the same way as the private database.Don’t forget to delete Subscriptions from CloudKitDashboard when testing as subscriptions will remain and fire, even if removed from your code.