How to make remote notification appear in notification center when app is in the foreground?

Viewed 210

When my app in in the foreground, it receives a push notification from my server, triggers my UNNotificationServiceExtension, and then triggers userNotificationCenter(_:willPresent:withCompletionHandler:). The notification appears at the top of the app for a couple seconds, but when I swipe the top of the phone to see the notification center, the notification isn't there.

If my phone is locked or the app is in the background while I receive the notification, then it does appear in the notification center.

How do I make the notification appear in the notification center while the app is in the foreground?

1 Answers

I think adding .list should do the trick

completionHandler([.badge, .banner, .sound, .list])

You can read more about UNNotificationPresentationOptions here.

Related