6

I am building an app that needs to subscribe to record changes in the public database of iCloud. Now, after watching the apple video's and reading their documentation, I decided to get to work. However, I immediately got stuck here:

enter image description here

All initialization methods on a CKSubScription are deprecated. This can be seen here, but meanwhile apple still seems to use the very same methods in their documentation here.

This left me surprised. Looking around on the web and SO, there doesn't seem too be much information or any tutorials available (at least, none with up to date info on initializing subscriptions), probably because this technology is relatively new and these changes are recent. I have very superficial experience with CloudKit, so I'd rather ask for a decent way to do this than to improvise something myself. My question is:

How to initialize a CKSubscription?

Obviously, if the entire idea of subscriptions is outdated I am open to any answer that will result in my app receiving pushes when records of specific types appear in my public database.

d4Rk
  • 6,622
  • 5
  • 46
  • 60
Joris416
  • 4,751
  • 5
  • 32
  • 59

2 Answers2

11

Seems like CKSubscription is really more or less deprecated.

According to http://iosdevetips.blogspot.de/2016/06/deprecated-apis-in-ios-10.html you should use CKRecordZoneSubscription and CKQuerySubscription now.


Update: Like Trevis pointed out, the docs are not really helpful here, but at least Xcode shows a somewhat helpful Warning: enter image description here

d4Rk
  • 6,622
  • 5
  • 46
  • 60
  • 2
    As a relatively new iOS dev, i find it really frustrating that their document doesn't tell you want the new hotness is when looking at the deprecated reference. Doesn't seem like a lot to ask. Thanks for your response. – Trevis Thomas Jul 01 '17 at 16:54
  • You're right, but at least Xcode shows a warning for that (see my updated answer) – d4Rk Jul 02 '17 at 07:51
  • This is probably wrong but if you are just getting started with iOS development, I'd suggest you ignore this warning and use that method anyway — deprecated methods won't go away in a few years, and before they do in the future, better documentations will definitely surface. – Teng L Jun 07 '18 at 09:36
  • @TrevisThomas: The new hotness is written right there: `Init the appropriate CKSubsription subclass`. What else do you want? – Mojo66 May 07 '20 at 12:14
  • There is also `CKDatabaseSubscription` that lets you also specify a record type to query. – Reinhard Männer Jul 19 '21 at 05:39
2

If you are looking for a new class to substitute Apple's own documentation, use CKQuerySubscription in place of CKSubscription. They have almost identical initializers.

Teng L
  • 297
  • 3
  • 17