CloudKit reference subscription requires CKReferenceActionDeleteSelf reference?

I've created a subscription for child record changes, based on a reference field to a parent record.


When I create a child record and set the child's parent reference with a CKReferenceActionNonereference, the subscription does not generate a push notification. If I use a CKReferenceActionDeleteSelf reference, the subscription works as expected, generating push notifications on all subscribed devices.

I do not want want cascading deletes. Why do I need to use a CKReferenceActionDeleteSelfreference to generate push notifications?


Here is the code:


    // subscription registration
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K == %@", @"parent_ref", _parentRecordID];
    CKSubscription *subscription = [[CKSubscription alloc] initWithRecordType:@"Child"
                                                                    predicate:predicate
                                                                      options: CKSubscriptionOptionsFiresOnRecordCreation|CKSubscriptionOptionsFiresOnRecordUpdate|CKSubscriptionOptionsFiresOnRecordDeletion];
    CKNotificationInfo *notificationInfo = [[CKNotificationInfo alloc] init];
    notificationInfo.alertBody = @"Alert body";
    notificationInfo.shouldBadge = YES;
    notificationInfo.shouldSendContentAvailable = YES;
    subscription.notificationInfo = notificationInfo;
    [_db saveSubscription:subscription
        completionHandler:^(CKSubscription *subscription, NSError *error) {
            // completes without error
    }];



    // child record construction
    CKReference *parentRef = [[CKReference alloc] initWithRecordID:_parentRecordID
                                                            action:CKReferenceActionNone];
    CKRecord *childRecord = [[CKRecord alloc] initWithRecordType:@"Child"];
    childRecord[@"parent_ref"] = parentRef;
    [_db saveRecord:childRecord completionHandler:^(CKRecord *record, NSError *error) {
        // completes without error, but does NOT generate a push notification.
        // HOWEVER, if parentRef.action is CKReferenceActionDeleteSelf instead of
        //      CKReferenceActionNone, then push notifications fire on other devices,
        //      as expected.
    }];


The -saveRecord: method completes without error, but does NOT generate a push notification. HOWEVER, if parentRef.action is CKReferenceActionDeleteSelf instead of CKReferenceActionNone, then push notifications fire on other devices, as expected.


Why would this be?

Hi.

I am facing a similar problem....just curious to know if you understood what the issue was.

Thanks

Hllo. I`m facing the same problem. Even with different `subscriptionID`s. Any luck in discovering reasons of it?

No, sorry, I did not find a workaround. I ended up simplifying my schema for other reasons, so did not pursue a solution.

In WWDC 2016 they said there is a "parent" property in CKRecord to use in order to establish hierarchical dependencies, so my question is: what about CKReference? and how to use, if the purpose is not a parent-child relationship... Anywhay, CKReference are useful to just link two records and setting the action to .deleteSelf or .none is just a part of that link.

CloudKit reference subscription requires CKReferenceActionDeleteSelf reference?
 
 
Q