cloudkit subscription error

i am trying to create subscriptions but i see some weird error popping out.

I have tried to search google and stackoverflow without any luck

Can someone help me please?

Code is the following



    func SottoscrizioneAccessori()->Void
    {
        if UserDefaults.standard.bool(forKey: "SUBACCESSORI_\(Manager.AI.StatoAttuale.NodoAI.PIVA)") == false
        {
            
            let predicate=NSPredicate(format: "RefAzienda = %@", Manager.AI.StatoAttuale.NodoAI.PIVA)
            let subscription=CKQuerySubscription(recordType: "CKAccessori",
                                                 predicate:predicate,
                                                 subscriptionID: "CKSUBACCESSORI",
                                                 options: [.firesOnRecordUpdate, .firesOnRecordCreation])
            let nInfo=CKNotificationInfo()
            
            nInfo.alertBody = "Accessori Aggiornati"
            nInfo.shouldBadge=false
            
            subscription.notificationInfo = nInfo
            Manager.AI.pubDB.save(subscription, completionHandler: { (retRecord, error) in
                if error != nil
                {
                    print("SUB_ACCESSORI - sottoscrizione fallita con errore \(error?.localizedDescription ?? "-err-")")
                }
                else
                {
                    print("SUB_ACCESSORI - sottoscrizione creata con successo")
                    UserDefaults.standard.set(true, forKey: "SUBACCESSORI_\(Manager.AI.StatoAttuale.NodoAI.PIVA)")

                }
            })
        }
    }

the database is the development one (tried also to force the production one and the error was that i cannot create subscription on production container


The error in the console is:

SUB_ACCESSORI - sottoscrizione fallita con errore Error saving record subscription with id CKSUBACCESSORI to server: Deployed schema UUID does not match supplied parent UUID.


the development database is already deployed in production... everything is "correct" (name of recordtype, fields, etc.etc.)...

i am not able to find this kind of error anywhere...

someone?

Answered by TheFinal in 348840022

I have found the problem

So for everyone else here who may find this kind of error: NEVER save multiple subscription without waiting the previous one has completed its cycle.

Now i wait for each single subscription and everything is fine.

funny thing is that i have several subscription, all with the same type of code but different recordtype name, and some fails, others are successfull, but from one run to another (erasing the subscription from dashboard) the successful are not always the same...

Accepted Answer

I have found the problem

So for everyone else here who may find this kind of error: NEVER save multiple subscription without waiting the previous one has completed its cycle.

Now i wait for each single subscription and everything is fine.

cloudkit subscription error
 
 
Q