Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get received PUSH notification list without tap on the notification

when i open the app ,I need to read all the push notifications which are received when phone is not active or background mode. "didReceiveRemoteNotification" method call when the notification tapped only, i want to read the notification without tapping

like image 790
Nithaparan Avatar asked Sep 08 '25 03:09

Nithaparan


1 Answers

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

let center = UNUserNotificationCenter.current()
center.getDeliveredNotifications(completionHandler: { (notificationRequests) in
            for x in notificationRequests {
            print(x.request.content.body)
        }
        })

Here is apple doc link https://developer.apple.com/documentation/usernotifications/unusernotificationcenter/1649520-getdeliverednotifications

Another way

These all remote push notification, pushed by your backend server via Apple cloud server. Better you request to your server to retrive all push notification payload in response and display to your client, Here you manage as per your need.

And then you clear notifications from notification tray.. like this.

application.applicationIconBadgeNumber = 0 // For Clear Badge Counts
let center = UNUserNotificationCenter.current()
center.removeAllDeliveredNotifications() // To remove all delivered notifications
center.removeAllPendingNotificationRequests() 
like image 199
SachinVsSachin Avatar answered Sep 10 '25 13:09

SachinVsSachin