How to get an already running UILocalNotification

I implement UILocalNotificationin my application and notifications are delivered as expected. As I understand it, notifications are handled as follows:

  • When the application is not running, and the user clicks on the notification, the application receives a notification through the parameters in the method applicationDidFinishLaunching.
  • When an application is active, it receives a notification using the method didReceiveLocalNotification.
  • When the application is in the background and the user clicks a notification, he receives a notification using the method didReceiveLocalNotification.

But there is one case that I could not cover, and this is when the notification was fired, the application is in the background, and the application is simply activated by clicking on the application icon (instead of clicking on the notification). In this case, no UILocalNotification. But I still would like to know that the notification has been fired since its last active action, since the notification has some information in which it will be entered in the property userInfo.

Currently, I have “solved” it by checking that the icon number is> 0 in applicationDidBecomeActive, but this allows me to show a general message to the user. I would rather find out which notification caused the icon number update. Is there any way to achieve this?

+4
1

. , !

NSUserDefaults, NSKeyedArchiver, NSData. , , , , .

NSKeyedUnarchiver, UILocalNotification. ( cancelLocalNotification).

.

0

Source: https://habr.com/ru/post/1534000/


All Articles