Whilst all current answers to this question indicate the depreciation of CKModifyBadgeOperation, all of them had advised up until 2022 that it could still be used due to Apple not having a replacement Api. Upon running the following code:
badgeReset.modifyBadgeCompletionBlock = { (error) -> Void in
if error != nil {
print("Error resetting badge: \(error!)")
}
}
CKContainer.default().add(badgeReset)
When run I receive the following error:
Error resetting badge: <CKError 0x3001ddf50: "Invalid Arguments" (12/1017); "CKModifyBadgeOperation is no longer supported">
And from testing following this, the badge count incrementation issue continues, indicating that this has been completely invalidated and cannot be used at all.
Even with UNUserNotificationCenter.current().setBadgeCount(0) this only clears the badge count temporarily.
I'm aware of the proposed "workaround" of creating an extension that manually keeps track of notification count & sets the badge accordingly when a notification is received. However I'm trying to ascertain if as of this current point in time there is now no way whatsoever to clear the badge count on the Cloudkit sever level?
Post
Replies
Boosts
Views
Activity
I am trying to create a specialised photo sharing social network using CloudKit alone. The app will never need to be non iOS, so on the surface Cloudkit has seemed like a perfect backend. However, I've found at random but semi frequent times, the loading of CKAssets from records can be very slow.
For example, at normal times, all of the assets can load in a second or less. However at other times, it can take from 5 to 15 seconds. This is on a public database using a fetch operation where I already have the record IDs. Here is my code that performs that:
mainDatabase.fetch(withRecordIDs: recordIDS, desiredKeys: ["image"]) { results in
var recordsToReturn: [CKRecord] = []
switch results {
case .success(let success):
for (_, result) in success {
switch result {
case .success(let record):
// If the result is success, append the record to the successfulRecords array
recordsToReturn.append(record)
break
case .failure(_):
break
}
}
completion(.success(recordsToReturn))
case .failure(let failure):
completion(.failure(failure))
}
}
}
Of note, I have also tried using a database operation at set the qualityOfService to userInitiated, which has had the same noticeable load times.
I have also tested this on different devices, on different networks (both cellular & different WiFi connections) and found also the same noticeable load times at random occurrences.
Therefore, what I am trying to find out:
Is this an expected behaviour from using CloudKit?
Is there a much better way to load CKAssets that would drastically help this load time issue?
Is CloudKit even a viable option for this kind of app, or is it not designed for this type of app?
What alternative approaches could be taken? (Eg. store assets in AWS...)
Would truly appreciate any feedback & guidance on this issue.