获取应用程序上次打开时收到的所有推送通知

问题描述:

我使用Xcode 8和CloudKit创建iOS 10应用程序。当应用程序加载时,是否有任何方法可以读取自上次运行应用程序以来发送的所有推送通知?获取应用程序上次打开时收到的所有推送通知

您可以调用下面的函数,request包含了所有的通知从IOS 10.x中我们可以得到待定交付

[[UNUserNotificationCenter currentNotificationCenter] 
getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotificationRequest 
_Nonnull requests) { 
      NSLog(@""); 
    }]; 
+0

iOS 9怎么样? – Jaybo

并交付使用UNUserNotificationCenter

你通知信息与应用的通知列表仍然显示在通知中心使用以下功能

func getDeliveredNotifications(completionHandler:@escaping([UNNotification]) - > Void)

refrer below link for more details

+1

我们可以在ios 9.x中获得待处理通知列表吗? – 2017-06-06 03:28:58