Nit*_*ran 3 push-notification ios firebase swift
当我打开应用程序时,我需要阅读手机未处于活动状态或后台模式时收到的所有推送通知.只有通知点击时才会调用" didReceiveRemoteNotification "方法,我想在不点击的情况下阅读通知
返回仍显示在"通知中心"中的应用程序通知列表.
let center = UNUserNotificationCenter.current()
center.getDeliveredNotifications(completionHandler: { (notificationRequests) in
for x in notificationRequests {
print(x.request.content.body)
}
})
Run Code Online (Sandbox Code Playgroud)
其他方式
这些所有远程推送通知,由您的后端服务器通过Apple云服务器推送.更好的是,您要求服务器检索所有推送通知有效负载并作为响应显示给您的客户端,您可以根据需要进行管理.
然后你清除通知托盘中的通知..像这样.
application.applicationIconBadgeNumber = 0 // For Clear Badge Counts
let center = UNUserNotificationCenter.current()
center.removeAllDeliveredNotifications() // To remove all delivered notifications
center.removeAllPendingNotificationRequests()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
282 次 |
| 最近记录: |