Remove call notifications on various points

This commit is contained in:
ismailgulek
2020-08-10 18:20:02 +03:00
parent c805f26fd7
commit bf09b7e419
4 changed files with 22 additions and 0 deletions
@@ -30,4 +30,15 @@ import UserNotifications
}
}
func removeCallNotifications() {
UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in
// get identifiers of notifications whose category identifiers are "TO_BE_REMOVED"
let identifiersToBeRemoved = notifications.compactMap({ $0.request.content.categoryIdentifier == Constants.callNotificationsCategoryIdentifier ? $0.request.identifier : nil })
NSLog("[UNUserNotificationCenter] removeUnwantedNotifications: Removing \(identifiersToBeRemoved.count) notifications.")
// remove the notifications with these id's
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: identifiersToBeRemoved)
}
}
}