Undo
Undo

Reputation: 25687

"CKSubscriptionTypeRecordZone subscriptions are incompatible with subscription options 7" when creating a subscription

I'm trying to use the following code to create a CloudKit subscription:

let container = CKContainer.defaultContainer()
let database = container.publicCloudDatabase
let recordZone = CKRecordZone.defaultRecordZone()

let subscription = CKSubscription(zoneID: recordZone.zoneID, options: .FiresOnRecordCreation | .FiresOnRecordUpdate | .FiresOnRecordDeletion)

database.saveSubscription(subscription) {(subscription: CKSubscription!, error: NSError!) in
    if error
    {
        NSLog("Error: %@", error)
    }
    else if subscription
    {
        NSLog("Saved subscription: %@", subscription)
    }
}

And it fails with this error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'CKSubscriptionTypeRecordZone subscriptions are incompatible with subscription options 7'

What does this mean, and how can I fix it? I want to be notified when a record is created, updated, or deleted.

Upvotes: 1

Views: 296

Answers (1)

Undo
Undo

Reputation: 25687

Duh! From the docs:

subscriptionOptions

The configuration options for the subscription. You must specify 0 for this parameter. Zone subscriptions currently do not support any options.

Specifying nil works, although I'm probably going to take a different approach.

Upvotes: 4

Related Questions