Dip*_*iya 2 ios dart firebase flutter
我有 flutter 应用程序,我在其中使用推送通知
当我收到新通知时,我会删除所有通知和徽章,但有时打开应用程序时通知徽章不会删除,并且它会不断增加
这是我找到的删除徽章的解决方案:-
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)
}
}
Run Code Online (Sandbox Code Playgroud)
但它不会删除我的徽章 有什么方法可以删除通知徽章吗?
AppDelegate.swift尝试在您身边添加以下代码didFinishLaunchingWithOptions
override func applicationDidEnterBackground(_ application: UIApplication){
application.applicationIconBadgeNumber = 0
}
Run Code Online (Sandbox Code Playgroud)
希望它对你有用
| 归档时间: |
|
| 查看次数: |
2214 次 |
| 最近记录: |