Do CloudKit subscriptions work from command line tool application?

I am able to fetch CloudKit records from my MacOS command line tool/daemon.

However, I would like CloudKit to notify my daemon whenever CKRecords were altered so I would not have to poll periodically.

In CloudKit console I see that my app successfully created CloudKit subscription, but the part that confuses me is where in my app do I define callback function that gets called whenever CloudKit attempted to notify my app of CloudKit changes?

My first question - do I need to define callback in my implementation of UNUserNotificationCenterDelegate? NSApplicationDelegate? Something else?

My second question, would CKSyncEngine work from command line application?

I am able to fetch CloudKit records from my MacOS command line tool/daemon.

I’d like to clarify what you mean by “daemon” in this context. On macOS that usually refers to a launchd daemon. This is run in a global execution context, independent of any user login context. For example, it’ll run when no user is logged in, or when multiple users are logged in.

Assuming that definition, CloudKit doesn’t make any sense for you because it depends on a user context.

Note Technote 2083 Daemons and Agents has a lot more detail about execution contexts. Some of the details are changed over the years, but the basic concepts are still valid.

Now, if you’re using “daemon” in a more general sense, that story might change. For example, macOS supports launchd agents, which run in a user login context and can do most user-y things.

So, how are you planning to run this program?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Do CloudKit subscriptions work from command line tool application?
 
 
Q