I have cloudkit notifications working. When someone changes the record, the subscribers are notified. My subscription definition looks like:
NSPredicate *searchConditions = [NSPredicate predicateWithFormat:@"%K = %@", CLOUDKIT_PUBLIC_ID_GUID, theCloudGUID];
int subscriptionOptions = CKSubscriptionOptionsFiresOnRecordUpdate | CKSubscriptionOptionsFiresOnRecordDeletion;
CKSubscription *publicSubscription = [[CKSubscription alloc] initWithRecordType:CLOUDKIT_RECORDNAME_PUBLIC_ID
predicate:searchConditions
options:subscriptionOptions];
CKNotificationInfo *notificationInfo = [CKNotificationInfo new];
notificationInfo.alertLocalizationKey = CLOUDKIT_NOTIFICATION_PUBLIC;
notificationInfo.shouldBadge = NO;
notificationInfo.alertBody = CLOUDKIT_NOTIFICATIONBODY_PUBLIC;
publicSubscription.notificationInfo = notificationInfo;
[publicDatabase saveSubscription:publicSubscription completionHandler:^(CKSubscription * _Nullable subscription, NSError * _Nullable error)
{
//error handling
}
The thing is, there are multiple fields in this record. I only want to alert the subscriber when one specific field changes.
When creating the subscription, is there a way to set the search predicate to detect a change in a specific field? I read through the various Predicate docs, but didn't see this specifically mentioned.
Or, when receiving the notification, is there a way to see which fields changed? In didReceiveRemoteNotification
I tried:
CKQueryNotification *queryNotification = [CKQueryNotification notificationFromRemoteNotificationDictionary:userInfo];
But queryNotification.recordFields
is null.
As a worst case, I have considered breaking the specific field out into it's own record, but then I have the overhead of maintaining more records tied together by a common GUID. I was hoping to keep this more compact.