Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash in resumeLongLivedOperationIfPossible #262

Open
Tliens opened this issue Jul 18, 2022 · 2 comments
Open

crash in resumeLongLivedOperationIfPossible #262

Tliens opened this issue Jul 18, 2022 · 2 comments

Comments

@Tliens
Copy link

Tliens commented Jul 18, 2022

please replace function resumeLongLivedOperationIfPossible like this

func resumeLongLivedOperationIfPossible() {
        container.fetchAllLongLivedOperationIDs { [weak self]( opeIDs, error) in
            guard let self = self, error == nil, let ids = opeIDs else { return }
            for id in ids {
                self.container.fetchLongLivedOperation(withID: id, completionHandler: { [weak self](ope, error) in
                    guard let self = self, error == nil else { return }
                    if let modifyOp = ope as? CKModifyRecordsOperation {
                        modifyOp.modifyRecordsCompletionBlock = { (_,_,_) in
                            print("Resume modify records success!")
                        }
                        // The Apple's example code in doc(https://developer.apple.com/documentation/cloudkit/ckoperation/#1666033)
                        // tells we add operation in container. But however it crashes on iOS 15 beta versions.
                        // And the crash log tells us to "CKDatabaseOperations must be submitted to a CKDatabase".
                        // So I guess there must be something changed in the daemon. We temperorily add this availabilty check.
//                        if #available(iOS 15, *) {
//                            self.database.add(modifyOp)
//                        } else {
//                            self.container.add(modifyOp)
//                        }
                    }
                })
            }
        }
    }
@Tliens
Copy link
Author

Tliens commented Jul 18, 2022

It's work very well

@Tliens
Copy link
Author

Tliens commented Jul 18, 2022

maybe self.container.fetchLongLivedOperation already did added this ope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant