Cloudkit:CKDatabaseOperation不支持蜂窝网络

时间:2015-12-09 21:36:56

标签: ios cloudkit cellular-network

您好所有CloudKit位用户:

我有一段可怕的时间试图找出为什么CKDatabaseOperation不会给出任何反馈。在蜂窝电话上保存CKRecords时没有错误,也没有回调。

请您告诉我您对此有何看法?

1 个答案:

答案 0 :(得分:6)

Apple开发者论坛中有人找到了解决方案: https://forums.developer.apple.com/thread/20047

设置qualityOfService = .UserInitiated

时会发生魔力

示例:

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)