I've seen a lot a similar questions but I have not found an answer to this specific scenario while running on Mac. If the app is off and a user notification comes in and the user taps on it, then the app is opened. Once the app is opened, how can it capture the notification so that it can handle its contents.
From what I can tell, the notification cannot be retrieved from [[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:
or [[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:
.
When the app is opened from the user tapping on the notification, it also does not seem to open through the UNUserNotificationCenterDelegate
functions. I don't see it in either willPresentNotification
or didReceiveNotificationResponse
and it's not handled by the appDelegate's didReceiveRemoteNotification:fetchCompletionHandler
On iOS in this situation, the notification arrives inside the launchOptions from application:didFinishLaunchingWithOptions
. There's key UIApplicationLaunchOptionsRemoteNotificationKey
contains the notification data. The same app running on Mac contains a nil launchOptions dictionary.
These are all the places that I've looked but I'm sure I must be missing something.