Let's say one of my users wants me to delete their iCloud data from my app's public database.
What's the best way to find that particular record in the CloudKit Dashboard?
Thank you!
Let's say one of my users wants me to delete their iCloud data from my app's public database.
What's the best way to find that particular record in the CloudKit Dashboard?
Thank you!
I don't think you can delete the original User
Record Type in CloudKit BUT if you made your own you can!
Make your own record Type then set a ID to it(you can use your ID that's linked to the original User
record by getting it using :
Lets call our own user record UserInfo
😉
public let container = CKContainer.init(identifier: "cloudkitIDDBName")
guard let recordID = recordID, error == nil else { return}
DispatchQueue.main.async {
self.cloudkitUserRecordID = recordID
}
}
Once you get the recordID save that somewhere in a property or something then when you create a User
😃
Then save a new UserInfo
(our own user record type) with the user's info you want to save something like below:
firstTimeUserRecord["userID"] = recordID
firstTimeUserRecord["username"] = username
container.publicCloudDatabase.save(firstTimeUserRecord) { newUserRecord, error in
//etc
}
then when you want to delete you can do like below
container.publicCloudDatabase.delete(withRecordID: self.recordID) { record, error in
//handle your errors :/etc
}