Limit for Local Notifications (UNNotificationRequest) in iOS 10
Asked Answered
E

3

13

I know that the limit of local notifications is 64 for UILocalNotification. It's written in Apple Dev Docs. But UILocalNotification is deprecated in iOS 10. Instead this one, Apple proposes to use UNNotificationRequest. But Apple Dev Docs doesn't say anything about limiting the count of notifications. I found this answer, but it doesn't have links to Apple Dev Docs or something like that (it's just an opinion). Does anyone know for sure about restrictions of local notifications? Maybe someone know the link to Dev Docs or is there an official response from Apple about this?

Elsyelton answered 15/4, 2017 at 8:44 Comment(0)
M
12

Although it's not officially documented, testing shows that UNNotificationRequest retains the 64 notification limit.

However, importantly, the way that they deal with the notification queue has changed. If there are more than 64 notifications:

  • UILocalNotification would keep the 64 soonest notifications
  • UNNotificationRequest keeps the 64 last set notifications

This may be a bug, and is documented in this radar.

Melisent answered 2/10, 2018 at 18:45 Comment(2)
Thanks for finding this out!!Headband
what about repeating notifications when you send 1 request to show multiple notifications? Does app count requests or notifications in this case?Yorgen
T
4

The IOS 12 version of UNNotificationCenter.h has in comments of (void)addNotificationRequest:(UNNotificationRequest *)request withCompletionHandler:(nullable void(^)(NSError *__nullable error))completionHandler; this:

Notification requests can be scheduled to notify the user via time and location. See UNNotificationTrigger for more information. Calling -addNotificationRequest: will replace an existing notification request with the same identifier. A notification request with the identifier as an existing delivered notifications will alert for the new notification request and replace the existing delivered notification when it is triggered. The number of pending notification requests that may be scheduled by an application at any one time is limited by the system.

Thach answered 18/9, 2019 at 18:46 Comment(1)
again - what if single request produces multiple notifications? So may number of notifications exceed 64?Yorgen
M
1

Yes indeed, I just checked for iOS 10.2 and the limit for the total number of UNNotificationRequest you can add is still 64.

Moncton answered 2/7, 2017 at 15:11 Comment(3)
Documentation for UNNotificationRequest doesn't mention it. Nor is it in the notification guide. Do you have an official source that mentions it? I don't doubt the limit exists, but would like to see if it is documented.Frausto
"An app can have only a limited number of scheduled notifications; the system keeps the soonest-firing 64 notifications (with automatically rescheduled notifications counting as a single notification) and discards the rest." (Source: developer.apple.com/documentation/uikit/…)Accessory
@LukasSchulze UILocalNotification is deprecated since iOS 10. New class UNNotificationRequest mentions no limit to schedule amount.Gabbi

© 2022 - 2024 — McMap. All rights reserved.