Hi, I was able to create subscriptions in my container with the following code, but now for some unknown reason, I can't create one anymore, and instead I get the error message in the title above.
Thanks so much for any assistance you may be able to extend!!!
Ed
func subscribe() { // Only proceed if you need to create the subscription. guard !UserDefaults.standard.bool(forKey: "didCreateClassTableSubscription") else { return } // Define a predicate that matches records with a tags field // that contains the word 'Swift'. //let predicate = NSPredicate(format: "TRUEPREDICATE") //let predicate = NSPredicate(format: "tags CONTAINS %@", "Swift") let predicate = NSPredicate(format: "userRef == %@", RYH.userRef) // Create a subscription and scope it to the 'FeedItem' record type. // Provide a unique identifier for the subscription and declare the // circumstances for invoking it. let subscription = CKQuerySubscription(recordType: "ClassTable", predicate: predicate, subscriptionID: "ClassTableCreate", options: .firesOnRecordCreation)
// Further specialize the subscription to only evaluate // records in a specific record zone. //subscription.zoneID = recordZone.zoneID // Configure the notification so that the system delivers it silently // and, therefore, doesn't require permission from the user. let notificationInfo = CKSubscription.NotificationInfo() notificationInfo.shouldSendContentAvailable = true subscription.notificationInfo = notificationInfo // Save the subscription to the server. let operation = CKModifySubscriptionsOperation( subscriptionsToSave: [subscription], subscriptionIDsToDelete: nil)
operation.modifySubscriptionsCompletionBlock = { subscriptions, deleted, error in if let error = error { // Handle the error. self.errorMsg = "RYHTVC.subscribe.error1. " self.errorMsg += error.localizedDescription as Any as! String self.queryError(self.errorMsg) } else { // Record that the system successfully creates the subscription // to prevent unnecessary trips to the server in later launches. UserDefaults.standard.setValue(true, forKey: "didCreateClassTableSubscription") } } // Set an appropriate QoS and add the operation to the private // database's operation queue to execute it. let ryhDB = CKContainer(identifier: RYH.containerIdentifier).publicCloudDatabase operation.qualityOfService = .utility ryhDB.add(operation) }