Reputation: 71
I make an App with Cloudkit subscription. (see this code). I tested developer mode, and work fine. I publish my App, and that is not working :( I get the following error message (Cloudkit Dashboard Log) error: BAD_REQUEST operation: subscription modify database: private zone: _zoneWide
let predicate = NSPredicate(value: true)
let subscription = CKQuerySubscription(recordType: "recordDT",
predicate: predicate,
subscriptionID: subscriptionID,
options: [.firesOnRecordCreation, .firesOnRecordDeletion, .firesOnRecordUpdate])
let notification = CKNotificationInfo()
notification.alertBody = "change cloudkit"
notification.shouldSendContentAvailable = true
subscription.notificationInfo = notification
publicDB.save(subscription) { result, error in
if let error = error {
print(error.localizedDescription)
}
}
What could be the problem?
Upvotes: 2
Views: 679
Reputation: 501
I had a similar issue. Worked fine on dev but failed on production. The cause was my production database had not been updated with schema changes that had been made to the dev database. CloudKit automatically changes the schema of the developer databases, but you must push those changes into production. (Which is by design and a very good design choice at that.) So, if you are still having the problem, go to CloudKit dashboard and publish your changes from the developer version of your database into production.
Upvotes: 1
Reputation: 71
I Found the root cause of the error :)
I saw this the icloudkit dashboard webpage "Subscription types are automatically created when your app creates a Query Subscription." This work fine the developer pages, but not true the production page :(
Must be use "deploy to production" function, after the subscripttion was created
Upvotes: 2
Reputation: 14070
Can you show your code for how you define publicDB
and subscriptionID
?
You might try saving the subscription using a CKModifySubscriptionsOperation
instead of a save
and see if it makes a difference.
let operation = CKModifySubscriptionsOperation(subscriptionsToSave: [subscription], subscriptionIDsToDelete: nil)
operation.modifySubscriptionsCompletionBlock = { saved, deleted, error in
if let error = error{
print(error)
}else{
print("Subscriptions saved: \(saved)\nSubscriptions deleted: \(deleted)")
}
}
publicDB.add(operation)
Upvotes: 0