I use the following function to display notifications (that part works).
func showNotification(_ body: String, _ config: Config){
let content = UNMutableNotificationContent()
content.body = body
content.userInfo = ["logFile": config.logFile]
let request = UNNotificationRequest(
identifier: UUID().uuidString,
content: content,
trigger: nil
)
UNUserNotificationCenter.current().add(request) { (error:Error?) in
if error != nil {
print(error?.localizedDescription ?? "Could not add notification")
}
}
}
When the app is not running and a user clicks on a notification in the notification center, I use the following function to try to get userInfo
, but the property is not present.
func applicationDidFinishLaunching(_ notification: Notification) {
DispatchQueue.main.async {
let alert = NSAlert.init()
alert.messageText = String(describing: notification.userInfo)
alert.runModal()
}
}
Why?