CloudKit正常工作,但是突然出现权限错误

时间:2019-11-08 12:53:53

标签: swift xcode cloudkit

过去两个星期我一直在使用CloudKit,今天早晨,当我试图保存记录时,我做了很多次以前的工作,我开始遇到权限错误

Error saving to CloudKit: <CKError 0x600001f48ed0: "Permission Failure" 
(10/2007); server message = "Operation not permitted"; uuid = 78FA3DD1- 
EA44-4701-9A7E-8291F076DD8F; container ID = "[CloudKit Container Name]"> - Error fetching auth tokens from server: 
Operation not permitted'

因此,我已经三重检查了它是否正在请求正确的容器(我在CloudKit上仅设置了两个容器,因此很容易检查。

我已关闭XCode并再次将CloudKit再次打开,以试图对其进行强制重置(不确定是否有任何帮助,但认为可以尝试)

万一需要,这就是我保存到CloudKit的方式(过去这段代码没问题。

func createRecord(title: String, type: String, comment: String) {
    let audioRecord = CKRecord(recordType: "Audio")

    audioRecord["title"] = title as CKRecordValue
    audioRecord["type"] = type as CKRecordValue
    audioRecord["comment"] = comment as CKRecordValue


    let audioURL = audioRecorder.getAudioURL()
    let audioAsset = CKAsset(fileURL: audioURL)
    audioRecord["audio"] = audioAsset

    DispatchQueue.main.async {
        CKContainer.default().publicCloudDatabase.save(audioRecord) { [self] record, error in
            //print(CKContainer.default())
            if let error = error {
                print("Error saving to CloudKit: \(error.self) - \(error.localizedDescription)")
            } else {
                print("Record has been successfully saved to CloudKit")
            }
        }
    }
}

0 个答案:

没有答案