2 Replies
      Latest reply on Feb 5, 2019 3:23 AM by TheFinal
      TheFinal Level 1 Level 1 (0 points)

        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?

        • Re: cloudkit subscription error
          TheFinal Level 1 Level 1 (0 points)

          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...

            • Re: cloudkit subscription error
              TheFinal Level 1 Level 1 (0 points)

              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.

              1 of 1 people found this helpful