s'il vous plaît j'ai un problème sur comment puis-je déclencher la notification locale à un moment précis? sans utilisateur déclencher et besoin de l'application au moment précis tiré une notification localenotification locale déclenchée à un moment précis
le mon code suivant:
ceci est pour obtenir la permission de de l'utilisateur
func registerLocal() {
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in
if granted {
print("Yay!")
} else {
print("D'oh")
}
}
}
// ce i planifier une notification locale func scheduleLocal() {
let center = UNUserNotificationCenter.current()
let content = UNMutableNotificationContent()
content.title = "Late wake up call"
content.body = "The early bird catches the worm, but the second mouse gets the cheese."
content.categoryIdentifier = "alarm"
content.userInfo = ["customData": "fizzbuzz"]
content.sound = UNNotificationSound.default()
var dateComponents = DateComponents()
dateComponents.hour = 3
dateComponents.minute = 19
dateComponents.day = 3
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
center.add(request)
center.removeAllPendingNotificationRequests()
}
// son i appeler des méthodes de thèses
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
registerLocal()
scheduleLocal()
return true
}
et quand je ferme mon application j'ai reçu aucune notification, s'il vous plaît aider comment puis-je déclencher la notification locale au moment précis
grâce