1

How do you check whether an image stored with CKAsset has changed in CloudKit?

CKNotification doc says about desiredKeys:

  • You can include a maximum of three keys in the array.
  • For the keys you specify, the allowable values are NSString, NSNumber, CLLocation, NSDate, and CKReference. You cannot specify keys whose values contain other data types.

CKAsset is not on the list

János
  • 32,867
  • 38
  • 193
  • 353

1 Answers1

2

If a CKAsset is changed, then you will receive a push notification. But indeed a subscription won't send you the CKAsset. So you know that something has changed but not what has changed. So you have to fetch the record yourself. If you want to know what has changed, then you have to compare the object to the previous value yourself. The keys that you specified are usually the keys that you also want to show in your push notification message. Since you probably want to use most values of a record, i think you will always fetch the complete record after a notification was received by your app.

Edwin Vermeer
  • 13,017
  • 2
  • 34
  • 58
  • 1
    what do you think, if and only if asset url is the same as before, can that mean the content / hash of the content is the same? – János Feb 12 '15 at 13:05
  • 1
    Very good question. I think you can only answer that question by executing some tests and assume that what you see will remain that way. The asset will be saved to your device where the url will contain some sort of quid id. Then just test what happens if you change the asset. Will you then get a new ID? And what happens if you update an other field. Will the url remain the same. But then since you already have fetched the record with the asset you could also create a hash of that yourself and compare it to the previous hash. – Edwin Vermeer Feb 12 '15 at 13:21
  • If I have to get the full record every time there is a change, I think my app may hit the 40 requests/sec limit, if I have more than 40 users? – Frank Sep 10 '16 at 22:16