ios - 取消应用程序图标标记(快速)执行问题

标签 ios swift notifications badge

嘿伙计们,所以我想做的是,当用户收到通知然后进入应用程序或在通知设置中清除它时,我想去除应用程序图标的标记

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

然后将其保存在后台

没有?

关于ios - 取消应用程序图标标记(快速)执行问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31768263/

相关文章:

iphone - 即使在实现 shouldAutorotateToInterfaceOrientation 后 View 也不会调整大小

iphone - 如何在 iPhone 中将标签拖放到 UIToolbarItem 上

ios - Swift 中的多个选择器 View

ios - NSNotification 不适用于 Swift 翻译(来自 Objective-C)

java - Android 通知状态栏中出现空红圈!

ios - 内存警告后将 viewDidUnload 发送到已释放的实例

ios - UIApplication -beginReceivingRemoteControlEvents 导致音乐应用接管音频

javascript - 苹果 TVML : Send APP to background when Menu button pressed on Siri remote

swift - ARKit – eulerAngles of Transform Matrix 4x4

android - 前台服务通知需要几秒钟才能显示