Matthias Nott
2026-04-01 0af9986262e53b232731408ad38e9fda3da2cfa2
ios/Runner/AppDelegate.swift
....@@ -8,8 +8,6 @@
88 _ application: UIApplication,
99 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
1010 ) -> Bool {
11
- application.applicationIconBadgeNumber = 0
12
- if #available(iOS 16.0, *) { UNUserNotificationCenter.current().setBadgeCount(0) }
1311 return super.application(application, didFinishLaunchingWithOptions: launchOptions)
1412 }
1513
....@@ -17,13 +15,18 @@
1715 GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
1816 }
1917
20
- // Clear badge when app becomes active
21
- override func applicationDidBecomeActive(_ application: UIApplication) {
22
- super.applicationDidBecomeActive(application)
23
- application.applicationIconBadgeNumber = 0
24
- if #available(iOS 16.0, *) { UNUserNotificationCenter.current().setBadgeCount(0) }
18
+ // Read badge count from Flutter's SharedPreferences (UserDefaults) and update icon
19
+ private func updateBadgeFromPrefs() {
20
+ // Flutter SharedPreferences stores ints with "flutter." prefix
21
+ let prefs = UserDefaults.standard
22
+ let count = prefs.integer(forKey: "flutter.badgeCount")
23
+ UIApplication.shared.applicationIconBadgeNumber = count
2524 }
2625
26
+ // Don't touch badge on resume — APNs sets it, Flutter decrements it on session view
27
+
28
+ // Badge handled by Flutter via platform channel on session switch and background
29
+
2730 // Forward APNs token registration to the push plugin
2831 override func application(
2932 _ application: UIApplication,