categories won't show up in notification even with notification service extension

I want to add a category to my push notification and I can't seem to get any success in my attempts. I tried StackOverflow, but nobody responded, so I'm trying here.

I thought it would be an issue with my Firebase Cloud Functions message payload, but it's not.

I have a function to set a category on my notification when interacted with:

Code Block
func configureCategory() {
    let viewAction = UNNotificationAction(identifier: "viewNewEvent", title: "View New Event", options: UNNotificationActionOptions.foreground)
    let viewCategory = UNNotificationCategory(identifier: "newEventCategory", actions: [viewAction], intentIdentifiers: [], options: [])
    UNUserNotificationCenter.current().setNotificationCategories(Set([viewCategory]))
  }

I then call this right before
Code Block
application.registerForRemoteNotifications()


From, reading many articles, I thought this would work, but my notification just ends up with no actions when i receive it and interact with it.

I even decided to create a UNNotificationServiceExtension, and add the identifier in that, but that didn't work either.

Code Block  override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
     
    if let bestAttemptContent = bestAttemptContent {
      
      bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
      bestAttemptContent.categoryIdentifier = "newEventCategory"
       
      contentHandler(bestAttemptContent)
    }
  }


If anybody knows how to do this properly and sees I'm missing something or placing something in the wrong spot, please point it out and let me know, thanks.

Hi, I am having the same problem now. any clue how to solve this? thanks

categories won't show up in notification even with notification service extension
 
 
Q