Continuation…
When I initially determine if they allowed notifications something in there isn’t correct. I need code asking if they allowed local notification To request authorisation, do this:
let center = UNUserNotificationCenter.current()
center.delegate = self
center.getNotificationSettings(completionHandler: { (settings) in
if settings.authorizationStatus == .notDetermined {
// Notification permission has not been asked yet, go for it!
// Notification permission was previously denied, go to settings & privacy to re-enable
center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
DispatchQueue.main.async {
// Enable or disable features based on authorization.
if !granted {
let alert = UIAlertController(title: NSLocalizedString("Notification ", comment: ""), message: "", preferredStyle: .alert)
alert.message = NSLocalizedString("Notifications disabled: Activate in Settings.", comment: "")
alert.addAction(UIAlertAction(title: NSLocalizedString("ok", comment: ""), style: .cancel) { in
// continue your work
})
self.present(alert, animated: true, completion: nil)
}
}
}
} else if settings.authorizationStatus == .denied {
DispatchQueue.main.async {
let alert = UIAlertController(title: NSLocalizedString("Notification ", comment: ""), message: "", preferredStyle: .alert)
// Enable or disable features based on authorization.
alert.message = NSLocalizedString("Notifications disabled: Activate in Settings.", comment: "")
alert.addAction(UIAlertAction(title: NSLocalizedString("ok", comment: ""), style: .cancel) { in
// continue your work
})
self.present(alert, animated: true, completion: nil)
}
} else if settings.authorizationStatus == .authorized {
// Notification permission was already granted
}
})
```
Note that date is never used (line 31)