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