diff --git a/flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.m b/flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.m index e669a3284..1b7d3b618 100644 --- a/flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.m +++ b/flutter_local_notifications/ios/Classes/FlutterLocalNotificationsPlugin.m @@ -210,35 +210,6 @@ - (void)handleMethodCall:(FlutterMethodCall *)call } } -- (void)pendingUserNotificationRequests:(FlutterResult _Nonnull)result - NS_AVAILABLE_IOS(10.0) { - UNUserNotificationCenter *center = - [UNUserNotificationCenter currentNotificationCenter]; - [center getPendingNotificationRequestsWithCompletionHandler:^( - NSArray *_Nonnull requests) { - NSMutableArray *> - *pendingNotificationRequests = - [[NSMutableArray alloc] initWithCapacity:[requests count]]; - for (UNNotificationRequest *request in requests) { - NSMutableDictionary *pendingNotificationRequest = - [[NSMutableDictionary alloc] init]; - pendingNotificationRequest[ID] = - request.content.userInfo[NOTIFICATION_ID]; - if (request.content.title != nil) { - pendingNotificationRequest[TITLE] = request.content.title; - } - if (request.content.body != nil) { - pendingNotificationRequest[BODY] = request.content.body; - } - if (request.content.userInfo[PAYLOAD] != [NSNull null]) { - pendingNotificationRequest[PAYLOAD] = request.content.userInfo[PAYLOAD]; - } - [pendingNotificationRequests addObject:pendingNotificationRequest]; - } - result(pendingNotificationRequests); - }]; -} - - (void)activeUserNotificationRequests:(FlutterResult _Nonnull)result NS_AVAILABLE_IOS(10.0) { UNUserNotificationCenter *center = @@ -269,41 +240,33 @@ - (void)activeUserNotificationRequests:(FlutterResult _Nonnull)result }]; } -- (void)pendingLocalNotificationRequests:(FlutterResult _Nonnull)result { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - NSArray *notifications = - [UIApplication sharedApplication].scheduledLocalNotifications; - NSMutableArray *> - *pendingNotificationRequests = - [[NSMutableArray alloc] initWithCapacity:[notifications count]]; - for (int i = 0; i < [notifications count]; i++) { - UILocalNotification *localNotification = [notifications objectAtIndex:i]; -#pragma clang diagnostic pop - NSMutableDictionary *pendingNotificationRequest = - [[NSMutableDictionary alloc] init]; - pendingNotificationRequest[ID] = - localNotification.userInfo[NOTIFICATION_ID]; - if (localNotification.userInfo[TITLE] != [NSNull null]) { - pendingNotificationRequest[TITLE] = localNotification.userInfo[TITLE]; - } - if (localNotification.alertBody) { - pendingNotificationRequest[BODY] = localNotification.alertBody; - } - if (localNotification.userInfo[PAYLOAD] != [NSNull null]) { - pendingNotificationRequest[PAYLOAD] = localNotification.userInfo[PAYLOAD]; - } - [pendingNotificationRequests addObject:pendingNotificationRequest]; - } - result(pendingNotificationRequests); -} -- (void)pendingNotificationRequests:(FlutterResult _Nonnull)result { - if (@available(iOS 10.0, *)) { - [self pendingUserNotificationRequests:result]; - } else { - [self pendingLocalNotificationRequests:result]; - } +- (void)pendingNotificationRequests:(FlutterResult _Nonnull)result NS_AVAILABLE_IOS(10.0) { + UNUserNotificationCenter *center = + [UNUserNotificationCenter currentNotificationCenter]; + [center getPendingNotificationRequestsWithCompletionHandler:^( + NSArray *_Nonnull requests) { + NSMutableArray *> + *pendingNotificationRequests = + [[NSMutableArray alloc] initWithCapacity:[requests count]]; + for (UNNotificationRequest *request in requests) { + NSMutableDictionary *pendingNotificationRequest = + [[NSMutableDictionary alloc] init]; + pendingNotificationRequest[ID] = + request.content.userInfo[NOTIFICATION_ID]; + if (request.content.title != nil) { + pendingNotificationRequest[TITLE] = request.content.title; + } + if (request.content.body != nil) { + pendingNotificationRequest[BODY] = request.content.body; + } + if (request.content.userInfo[PAYLOAD] != [NSNull null]) { + pendingNotificationRequest[PAYLOAD] = request.content.userInfo[PAYLOAD]; + } + [pendingNotificationRequests addObject:pendingNotificationRequest]; + } + result(pendingNotificationRequests); + }]; } /// Extracts notification categories from [arguments] and configures them as