Can't Get `fetchAllSubscriptionsOperation()` to Work

I'm trying to get all the CKSubscriptions associated with the current user. I am trying this:


        let op = CKFetchSubscriptionsOperation.fetchAllSubscriptionsOperation()
        op.fetchSubscriptionCompletionBlock = { (subs, error) in
            print("*** fetched subs: \(subs)")
        }
        let q = OperationQueue()
        q.addOperation(op)


This call doesn't seem to work properly: I get an empty dictionary in the `subs` parameter. The `error` param is nil.


I happen to know that subscriptions for the user exist because calling `publicDatabase.fetchAllSubscriptions()` function works as I expect: it returns all subscriptions in the schema, including the current user's.


Can anyone let me know if I am doing something wrong or if there is some other way to get this information from CloudKit?


Thank you

Accepted Reply

I have confirmed that setting the database fix my problem. Since you compared it to the `publicDatabase.fetchAllSubscriptions()` convenience method, I expect it will fix your problem too.

Replies

I am seeing the same behaviour. But, I just had a thought that I can't check until tonight. I expect it defaults to the Private Database. If you set the database to the Public one I expect it to work.

I have confirmed that setting the database fix my problem. Since you compared it to the `publicDatabase.fetchAllSubscriptions()` convenience method, I expect it will fix your problem too.

Thank you. Yes, I just got the answer separately on StackOverflow. I don't know for sure if it defaults to the private database, but setting the database definitely makes it work for the public.