we need to put a different kind of code in AppDelegate.swit for iOS push notification. Flutter default code is not enough this.
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func applicationDidEnterBackground(_ application: UIApplication){
application.applicationIconBadgeNumber = 0
}
}
We did two things here, first we added support for older device.
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
and we also added support for background notification badge
override func applicationDidEnterBackground(_ application: UIApplication){
application.applicationIconBadgeNumber = 0
}