Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudKit fetch all subscriptions from the current user

I manage to save, change and delete records in Apples CloudKit. I even got notifications working with subscriptions, what I can not find out is, how do i list all subscriptions for the current user.

Here is my code so far:

let operation = CKFetchSubscriptionsOperation()
operation.fetchSubscriptionCompletionBlock = { (d, e) -> Void in
    println("got subscription")
    if e != nil {
        println("Error")
        dump(e)
    }
    dump(d)
}
publicDatabase.addOperation(operation)

What I got is:

got subscription
Error
- <CKError 0x14db0ed0: "Invalid Arguments" (12)> #0
- 0 key/value pairs

What are the Invalid Arguments? And how do i get a list of all saved subscriptions?

like image 638
Peter Shaw Avatar asked Dec 14 '22 18:12

Peter Shaw


1 Answers

If you want to do something with your subscriptions, then you could use something like this:

var database = CKContainer.defaultContainer().publicCloudDatabase
database.fetchAllSubscriptionsWithCompletionHandler({subscriptions, error in
        for subscriptionObject in subscriptions {
            var subscription: CKSubscription = subscriptionObject as CKSubscription
            ..
        }
    }
like image 55
Edwin Vermeer Avatar answered Feb 14 '23 04:02

Edwin Vermeer