BadgeProcessor.swift 603 B

12345678910111213141516171819
  1. //
  2. // BadgeProcessor.swift
  3. // NotificationServiceExtension
  4. //
  5. // Created by huangfeng on 2024/5/29.
  6. // Copyright © 2024 Fin. All rights reserved.
  7. //
  8. import Foundation
  9. /// 通知角标
  10. class BadgeProcessor: NotificationContentProcessor {
  11. func process(identifier: String, content bestAttemptContent: UNMutableNotificationContent) async throws -> UNMutableNotificationContent {
  12. if let badgeStr = bestAttemptContent.userInfo["badge"] as? String, let badge = Int(badgeStr) {
  13. bestAttemptContent.badge = NSNumber(value: badge)
  14. }
  15. return bestAttemptContent
  16. }
  17. }