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?