I'm deliberating on whether to use CloudKit for an app that requires sharing data amongst self-created groups of users (for e.g. sharing company-wide directories). I would use a public database for this, but I had a couple of questions:
- if I create a subscription to listen to record changes for a partcular record type, will all the users get a notification when data changes, or only the logged-in iCloud user amongst his/her multiple devices? can there by 'group' notifications that cross iCloud users?
- if there's no way for a 'group' of users to get notifications, I guess polling from the app to CloudKit would work, with the groupID part of the predicate? Or is there another options?
Thanks.
A more complete quote would be:
".......But all users in a group can individually create a subscription to.....changes in a single file in the public database. If that file is changed by any user then all users will get the notification."
So all users get the notification if all users create a subscription.
{But if one user creates a subscription UNDER A SPECIFIC iCLOUD ACCOUNT then all devices logged into that iCloud Account will get the notification. That usually is all of that user's devices. But it could also be the iPhone of that user's spouse or it might not be that user's iPad. Subscriptions and Notifications are based on iCloud Accounts not devices.}
My app, Carpooling: Princeton Ride Share, has a public database record type "Messages". All users subscribe to CKSubscriptionOptionsFiresOnRecordCreation using a predicateWithFormat:"ToNumber == %i",userIDNumber . Other users then create a CKRecord in Messages with a ToNumber equal to the userIDNumber of the user to whom they want to send a message. All user's subscriptions check that new record but because of their predicate, only that one user's devices get the notification. (That user then downloads the appropriate messages based on a query with the same predicate.) I think what you want to do is this, but instead of userIDNumber you will use groupIDNumber in the CKRecord and in the predicate.