import Flutter import UIKit import UserNotifications @main @objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { application.applicationIconBadgeNumber = 0 if #available(iOS 16.0, *) { UNUserNotificationCenter.current().setBadgeCount(0) } return super.application(application, didFinishLaunchingWithOptions: launchOptions) } func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) } // Clear badge when app becomes active override func applicationDidBecomeActive(_ application: UIApplication) { super.applicationDidBecomeActive(application) application.applicationIconBadgeNumber = 0 if #available(iOS 16.0, *) { UNUserNotificationCenter.current().setBadgeCount(0) } } // Forward APNs token registration to the push plugin override func application( _ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data ) { super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) } override func application( _ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error ) { super.application(application, didFailToRegisterForRemoteNotificationsWithError: error) } // Forward notification presentation (foreground) override func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void ) { super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler) } // Forward notification tap override func userNotificationCenter( _ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void ) { super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler) } }