0

I have an app that will show a notification icon when the user has not been to the app in awhile I can get it to clear when I launch the app but I want it to clear when they swipe clear from their phone notifications. The code I use to clear when I open the app is

 UIApplication.shared.applicationIconBadgeNumber = 0

I just started using swift today to help a coworker on their project. If anyone could point me in right direction at least would be appreciated.

Dima
  • 23,484
  • 6
  • 56
  • 83

1 Answers1

0

Sorry but you can't "launch code" from your application if your app is not opened. Maybe you could use a shortcut with 3D Touch "Clear" or something more user friendly that would clear the notification badge without launching the app.

You can take a look at the officiel documentation here .

Nicolas Charvoz
  • 1,509
  • 15
  • 41
  • When the user taps 3D Touch option it's also lunches the app and anyway, this isn't what this feature should do, the usage of it is to perform main actions in your app without the needing of open it and tap buttons in it (such as take a note, open camera on portrait mode, navigate to home and etc.) – Ido Jan 21 '19 at 20:52