Hey Guys donc ce que je suis en train de faire est lorsque l'utilisateur reçoit une notification passe ensuite dans l'application ou efface dans les paramètres de notification Je veux debadge l'icône de l'applicationicône app unbadging (rapide) des problèmes d'exécution
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()
}
Pour les deux assurez-vous qu'il est en fonction AppDelegate didFinishLaunchingWithOptions et vous saveInBackground. – tymac