I have some boilerplate code for when I'm working with iCloud. But recently with the IOS update many functions I've used are depreciated. Xcode tells me to read the "Sharing CloudKit Data with Other iCloud Users" section on the documentation, which I didn't find very helpful.
func getPermission() async throws -> CKContainer.ApplicationPermissionStatus{
let permission = try await CKContainer.default().requestApplicationPermission([.userDiscoverability])
switch permission{
case .granted:
return CKContainer.ApplicationPermissionStatus.granted
case .couldNotComplete:
throw CKError(.internalError)
case .denied:
throw CKError(.permissionFailure)
case .initialState:
return CKContainer.ApplicationPermissionStatus.denied
default:
fatalError("UNKNOW ERROR!!")
}
}
This is one of the functions, but I'm sure once I get this I'll be able to figure the others one out.
Currently the ApplicationPermissionStatus and the requestApplicationPermission() are deprecated.