I am currently migrating an app to the new UserNotifications framework. I'm stuck at detecting if the app was launched due to the user opening a local notification. The test case is:
- Schedule a local notification
- Manually close the app
- Setup Xcode to automatically attach when app is launched
- Wait for the notification to show and open it (default action)
The problem is that in this case userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:
is not called. In application:didFinishLaunchingWithOptions:
there is a key UIApplicationLaunchOptionsLocalNotificationKey
which contains an object of type UIConcreteLocalNotification
which is a subclass of UILocalNotification
. However, as part of the old notification system, UILocalNotification
is deprecated and we are not supposed to use it. I dug in the documentation and the web and did not find an answer to my question:
How do I find if an app was launched due to a local notification?
How do I obtain that notification?