See:https://www.hackingwithswift.com/read/33/8/delivering-notifications-with-cloudkit-push-messages-ckquerysubscription
let database = CKContainer.default().publicCloudDatabase
database.fetchAllSubscriptions { [unowned self] subscriptions, error in
if error == nil {
if let subscriptions = subscriptions {
for subscription in subscriptions {
database.delete(withSubscriptionID: subscription.subscriptionID) { str, error in
if error != nil {
// do your error handling here!
print(error!.localizedDescription)
}
}
}
// more code to come!
}
} else {
// do your error handling here!
print(error!.localizedDescription)
}
}