Modifica: Quindi mettere l'app in background ha funzionato.Aggiungi notifica locale in ios10 - swift 3
originale:
Così ho cercato di aggiungere una notifica al nuovo UNUserNotificationCenter, ma non mi sembra di farlo.
mio controller della vista ha un'azione:
@IBAction func sendPressed(_ sender: AnyObject) {
let content = UNMutableNotificationContent()
content.title = "Hello"
content.body = "What up?"
content.sound = UNNotificationSound.default()
// Deliver the notification in five seconds.
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5, repeats: false)
let request = UNNotificationRequest.init(identifier: "FiveSecond", content: content, trigger: trigger)
// Schedule the notification.
let center = UNUserNotificationCenter.current()
center.add(request) { (error) in
print(error)
}
print("should have been added")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let center = UNUserNotificationCenter.current()
center.requestAuthorization([.alert, .sound]) { (granted, error) in
}
}
e ho un Notification Content Extension
nel progetto pure, ma non sembra essere attivato a tutti, tutte le idee che cosa mi manca? Sto provando l'esempio dalla documentazione dell'utente, ma non mi sta dicendo altro o l'ho perso.
Qui: https://developer.apple.com/reference/usernotifications/unmutablenotificationcontent
anche: https://developer.apple.com/reference/usernotificationsui https://developer.apple.com/reference/usernotifications
è possibile fare riferimento questo link per l'uso dettagliate http://jayprakashdubey.blogspot.in/2016/07/local- notification-in-ios-10-for_31.html –
come impostare diversi componenti della data o come richiamare le notazioni locali più volte? – ArgaPK