# Mechanism to know if app is open in UNNotificationServiceExtension

**URL:** <https://forums.swift.org/t/mechanism-to-know-if-app-is-open-in-unnotificationserviceextension/59573>\
**Category:** Using Swift\
**Created:** [August 10, 2022, 7:24pm UTC](https://forums.swift.org/t/mechanism-to-know-if-app-is-open-in-unnotificationserviceextension/59573 "2022-08-10T19:24:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoKey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nokey/32/20598_2.png) [@NoKey](https://forums.swift.org/u/NoKey)\
**Post date:** [August 10, 2022, 7:24pm UTC](https://forums.swift.org/t/mechanism-to-know-if-app-is-open-in-unnotificationserviceextension/59573/1 "2022-08-10T19:24:44Z")

</div>

I am using `UNNotificationServiceExtension` to determine the push notification data. I need to change the push notification data depending on the current app state. I have a Notification screen in my app which shows important notifications to the user. E.g.: when a user is mentioned in a conversation, an entry will be added to the notification list. That is the job of `UNNotificationServiceExtension`, creating an notification entry (can not be changed).

When the conversation is already open, I want to skip inserting a row in the Notification list. I can track open conversations in a database, but when the application is shutdown and no clean up ran, the `UNNotificationServiceExtension` class assumes the conversation is still open (because the application code could not clean the open conversation table).

So to determine if a conversation is open in `UNNotificationServiceExtension`, I thought I could check that if the app is open AND the database says the conversation screen is open, then I know I can skip the notification entry.

What is the best way to check in `UNNotificationServiceExtension` if the app is completely shutdown/open?
