I have flutter app and I use push notification in it
When I receive new notification I remove all notification and badge but sometimes notification badge not remove when open app and it keep increasing
Here is solution I found to remove badge:-
Ios->appDelegete.swift
import UIKit
import Flutter
import Firebase
import UserNotifications
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
if #available(iOS 10.0, *) {
application.applicationIconBadgeNumber = 0 // For Clear Badge Counts
let center = UNUserNotificationCenter.current()
center.removeAllDeliveredNotifications()
center.removeAllPendingNotificationRequests()
center.delegate = self as? UNUserNotificationCenterDelegate
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
But it don't remove my badge is there any way to remove notification badge?
Try to Add Below Code In side you AppDelegate.swift
after didFinishLaunchingWithOptions
override func applicationDidEnterBackground(_ application: UIApplication){
application.applicationIconBadgeNumber = 0
}
Hope it's work for you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.