Je veux tirer la notification locale chaque année à des dates spécifiques, mais toutes les notifications ont un titre et un corps différents, voici mon code que j'ai écrit et qui fonctionne parfaitement, mais pour une notification seulement et la seconde une partie est après avoir obtenu notification mon icône de l'application ont 1, signifie une notification là comment supprimer ce? ..Notification locale à différentes dates Swift 3
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UIApplication.shared.statusBarStyle = .default
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]){ (allowed, error) in
UNUserNotificationCenter.current().delegate = self
scheduleNotification()
return true
}
func scheduleNotification() {
var date = DateComponents()
date.year = 2017
date.month = 6
date.day = 12
date.hour = 22
date.minute = 39
let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: false)
let content = UNMutableNotificationContent()
content.title = "Schedule Notification"
content.body = "Today is my Birthday"
content.sound = UNNotificationSound.default()
content.badge = 1
let request = UNNotificationRequest(identifier: "textNotification", content: content, trigger: trigger)
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
UNUserNotificationCenter.current().add(request) {(error) in
if let error = error {
print("error: \(error)")
}
}
apprécier et merci à l'avance
Vous devez planifier plusieurs notifications; un pour chaque date requise. Si vous ne voulez pas badger l'icône de l'application, ne définissez pas la propriété 'badge' – Paulw11
merci @ Paulw11 donc votre réponse rapide .. – King