私はCKFetchRecordZoneChangesOptions
で削除レコードを取得できない理由はわかりませんが、作成して変更したレコードを取得できますが、delete
はレコードを削除できません。
昨日、変更履歴を正常に取得できます。スウィフトクラウドキットCKFetchRecordZoneChangesOptionsは削除レコードを返すことができません
は、ここに私のコード
public func handleNotification(whichNotification : Int) {
zoneID = UserDataCustomZone.zoneID
if #available(iOS 10.0, *) {
// Use the ChangeToken to fetch only whatever changes have occurred since the last
// time we asked, since intermediate push notifications might have been dropped.
var changeToken: CKServerChangeToken? = nil
let changeTokenData = UserDefaults.standard.data(forKey: serverChangeTokenKey)
if changeTokenData != nil {
changeToken = NSKeyedUnarchiver.unarchiveObject(with: changeTokenData!) as! CKServerChangeToken?
}
let options = CKFetchRecordZoneChangesOptions()
options.previousServerChangeToken = changeToken
let optionsMap = [zoneID!: options]
let operation = CKFetchRecordZoneChangesOperation(recordZoneIDs: [zoneID!], optionsByRecordZoneID: optionsMap)
operation.fetchAllChanges = true
// only can receive created and modified change record
operation.recordChangedBlock = { record in
//show record
print("check this out \(record)")
}
}
operation.recordZoneChangeTokensUpdatedBlock = { zoneID, changeToken, data in
print("print Token \(String(describing: changeToken))")
guard let changeToken = changeToken else {
return
}
let changeTokenData = NSKeyedArchiver.archivedData(withRootObject: changeToken)
UserDefaults.standard.set(changeTokenData, forKey: self.serverChangeTokenKey)
}
operation.recordZoneFetchCompletionBlock = { zoneID, changeToken, data, more, error in
guard error == nil else {
return
}
guard let changeToken = changeToken else {
return
}
let changeTokenData = NSKeyedArchiver.archivedData(withRootObject: changeToken)
UserDefaults.standard.set(changeTokenData, forKey: self.serverChangeTokenKey)
}
operation.fetchRecordZoneChangesCompletionBlock = { error in
guard error == nil else {
return
}
}
operation.qualityOfService = .utility
let container = CKContainer.default()
let db = container.privateCloudDatabase
db.add(operation)
} else {
// Fallback on earlier versions
}
}
Cloudkinのデータを削除すると、サブスクリプションのリモート通知が取得できます。 – RiceEater