0

I have an iOS app that supports iOS 10 and above and it's working fine, now I want to support iOS 9 I have the following code that is working fine on iOS 10:

let ceneter = UNUserNotificationCenter.current()
        var idsToRemove = [String]()
        ceneter.getDeliveredNotifications { (notificatios) in
            for notifc in notificatios {
                if let type = notifc.request.content.userInfo["ntf_type"] as? String {
                    if type == "13" {
                        idsToRemove.append(notifc)
                    }
                }
            }
            ceneter.removeDeliveredNotifications(withIdentifiers: idsToRemove)
        }

What is the equivalent to the above code that would run on iOS 9? or how I can remove a specific notification?

I'm using Xcode 11.5 with swift 4.2

  • https://stackoverflow.com/questions/37956482/registering-for-push-notifications-in-xcode-8-swift-3-0 – Keshu R. Jun 15 '20 at 11:59
  • @KeshuR. thank you, but it's a different topic – Ibrahim Zakarya Jun 15 '20 at 12:09
  • Check [UILocalNotification in iOS 9 and UNMutableNotificationContent in iOS 10?](https://stackoverflow.com/questions/42363610/uilocalnotification-in-ios-9-and-unmutablenotificationcontent-in-ios-10) and [Local and Push Notifications in IOS version compatible](https://stackoverflow.com/q/42688760). – Martin R Jun 15 '20 at 12:11
  • @MartinR I've edited my question, I want to remove a specific notification not all of them – Ibrahim Zakarya Jun 15 '20 at 12:29
  • @IbrahimZakarya In case you didn't know after June 30th all Apple app submissions will require iOS 13 or higher: https://stackoverflow.com/a/60963349/4833705 – Lance Samaria Jun 15 '20 at 14:53
  • @LanceSamaria I don't think this will affect my app since I'm using Xcode 11 – Ibrahim Zakarya Jun 16 '20 at 14:09
  • oh ok, I was just pointing it out in case you didn't know. Cheers! – Lance Samaria Jun 16 '20 at 14:14

0 Answers0