0

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.

David
  • 4,665
  • 4
  • 34
  • 60
Progeny
  • 672
  • 1
  • 11
  • 25
  • Could you try removing the subscription and creating it again? After a model change you often need to do that. – Edwin Vermeer Apr 30 '15 at 08:10
  • UPDATE: if the field "list" that is a CKReference has the DeleteSelf action, the notification wouldn't fire, if the action is None, the notification fires. BTW I need the DeleteSelf for consistency – Progeny Apr 30 '15 at 09:37

1 Answers1

0

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.

Progeny
  • 672
  • 1
  • 11
  • 25