#ios `getPendingNotificationRequestsWithCompletionHandler:`是 iOS 用户通知框架类中的一个方法`UNUserNotificationCenter`。它允许您检索任何已安排但尚未交付的待处理通知请求。 ### 用法 使用此方法的方法如下: 1. **导入用户通知框架**: 确保在文件顶部导入框架: ``` objc @import UserNotifications; ``` **请求待处理通知**: 2. 您可以调用此方法来获取待处理的通知请求数组: ``` objc UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray * _Nonnull requests) { for (UNNotificationRequest *request in requests) { NSLog(@"Pending notification: %@", request.content.title); // You can also access other properties of the request } }]; ``` ### 笔记 - 完成处理程序提供了一个对象数组`UNNotificationRequest`,每个对象代表一个计划的通知。 - 您可以使用此方法在通知发送之前管理或修改通知,或者只是检查哪些通知处于待处理状态。