大家好,我想做的是,当用户收到通知后进入应用程序或在通知设置中清除它时,我想对应用程序图标进行标记

import UIKit

class TechByteSchedulingViewController:UIViewController  {

    @IBOutlet weak var datePicker: UIDatePicker!

    @IBAction func DateChosen(sender: UIButton) {
        self.sendNotification()
    }

    func sendNotification() {

        var localNotification = UILocalNotification()
        localNotification.fireDate = datePicker.date
        localNotification.repeatInterval = .CalendarUnitDay
        localNotification.alertBody = "check out your Daily Tech Byte"
        localNotification.alertAction = "Open"
        localNotification.timeZone = NSTimeZone.defaultTimeZone()
        localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
        localNotification.soundName = UILocalNotificationDefaultSoundName
        UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

}
    func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
        UIApplication.sharedApplication().applicationIconBadgeNumber = 1
        UIApplication.sharedApplication().applicationIconBadgeNumber = 0
        UIApplication.sharedApplication().cancelAllLocalNotifications()

    }

最佳答案

我以为是

application.applicationIconBadgeNumber = 0


要么

currentInstalltion.badge = 0


然后将其保存在后台

没有?

10-08 14:00