Cloudkit: CKDatabaseOperation not working on cellular

与世无争的帅哥 提交于 2019-12-06 14:27:54

Someone in the Developer Forums of Apple found a solution: https://forums.developer.apple.com/thread/20047

the magic happens when setting qualityOfService = .UserInitiated

Example:

let publicDB = CKContainer.defaultContainer().publicCloudDatabase    
let operation = CKModifyRecordsOperation(recordsToSave: [aRecord], recordIDsToDelete: nil)

operation.allowsCellularAccess = true
operation.qualityOfService = .UserInitiated // <----- THATS THE CELLULAR FIX

operation.perRecordProgressBlock = {(record, progress) in
    print("Progress: \(Int(progress*100.0))%")
}
operation.perRecordCompletionBlock = {(record, error) in
    print("Upload complete") //Add awesome error handling here
}
publicDB.addOperation(operation)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!