1

I have recently added iCloud into my iOS15, when I want to reset badge notifications with CKModifyBadgeOperation(badge:0), I have this warning: 'CKModifyBadgeOperation' was deprecated in iOS 11.0: No longer supported, will cease working at some point in the future

Is there another way?

func notificationsBadgeReset(){
    let badgeReset = CKModifyBadgeOperation(badgeValue: 0)
    badgeReset.modifyBadgeCompletionBlock = { (error) -> Void in
            if error != nil {
                print("Error resetting badge: \(error!)")
            }else {
                DispatchQueue.main.async {
                    UIApplication.shared.applicationIconBadgeNumber = 0
                }
            }
    }
    CKContainer(identifier: "ICloud.AppName").add(badgeReset)
}
AdR
  • 572
  • 1
  • 4
  • 13
  • [This](https://levelup.gitconnected.com/how-to-reset-badge-value-of-cloudkit-remote-notification-on-ios-ipados-15-46726a435599) may answer your question. – Yrb Feb 05 '22 at 16:46

1 Answers1

0

This is a duplicate of:

CKModifyBadgeOperation is deprecated in iOS 11. Anyone know an alternative approach?

You can continue to use it as Apple realizes that they have not created a replacement API yet. You can reset the badge from within the app but that does not affect what CloudKit thinks the count is and CloudKit will increment it from the non zero value.

Peter B. Kramer
  • 16,385
  • 1
  • 16
  • 20