CloudKit and CKSubscriptions

212 Views Asked by At

I'm addressing a very strange issue about CloudKit and push notifications provided by Apple with CKSubscriptions.

Firstly, everything is working fine, I'm able to receive a CKNotification, it worked for some days till I made some changes to the development schema, I just added a new field, nothing else, nothing weird.

From that moment, I'm unable to receive CKNotifications. I'm certainly sure I didn't made any mistakes with the code because I didn't change it. I've only added a new field in my schema from the Cloud Dashboard.

I'm the only one addressing this issue? Do you know whether a fix exists?

Thanks.

UPDATE: if the field "list" that is a CKReference, if the DeleteSelf action is set, the notification wouldn't fire, if the action is None, the notification fires. BTW I need the DeleteSelf.

1

There are 1 best solutions below

0
On

SOLVED:

The mistake was that the CKSubscription was firing in the way:

let listReference = CKReference(recordID: r.recordID, action: CKReferenceAction.None)                    
let predicate = NSPredicate(format: "%K == %@", "list", listReference)
                let itemsSubscription = CKSubscription(recordType: "Items", predicate: predicate, subscriptionID: "ITEMS", options: CKSubscriptionOptions.FiresOnRecordCreation | CKSubscriptionOptions.FiresOnRecordUpdate | CKSubscriptionOptions.FiresOnRecordDeletion)

but the reference action is now DeleteSelf

so changing to

let listReference = CKReference(recordID: r.recordID, action: CKReferenceAction.DeleteSelf) 

will do the trick.

Now is working fine.