Kacy
Kacy

Reputation: 3430

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

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?

Upvotes: 2

Views: 811

Answers (1)

Prasad Parab
Prasad Parab

Reputation: 409

I think adding .list should do the trick

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

You can read more about UNNotificationPresentationOptions here.

Upvotes: 3

Related Questions