UNUserNotificationCenter.current().getDeliveredNotifications only ever returns an empty array

后端 未结 2 913
自闭症患者
自闭症患者 2021-02-20 16:49

Basically, I\'m simply trying to print the notifications that my app has delivered, but doing something like:

UNUserNotificationCenter.current().getDeliveredNoti         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-20 17:49

    I did face the same problem with getDeliveredNotification, the array of notifications were always empty.

    So, I realized that I was setting [UIApplication sharedApplication].applicationBadgeNumber to 0, what clear all remote notifications from notification center.

    Now I set applicationBadgeNumber to 0 only after I get all pending notifications.

提交回复
热议问题