How to check which notifications are active in status bar in iOS?

iOSApps/ApplicationsMobile Development

To get the list of notifications which are active on your status bar tray we are going to use getdeliverednotifications, you can read more about it here.

https://developer.apple.com/documentation/usernotifications/unusernotificationcenter

https://developer.apple.com/documentation/usernotifications/unusernotificationcenter/1649520-getdeliverednotifications

While it is know that we cannot get the notifications from all apps as that would be a privacy violation, but we can get the notification for our application

Apple provide getDeliveredNotifications(completionHandler:)

Which returns a list of the app’s notifications that are still displayed in Notification Center.

You can write the following code depending upon your need.

UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in
   print(notifications)
}
raja
Published on 24-May-2019 11:51:55
Advertisements