Allow Custom (Sunrise/Sunset) Notification Triggers or remove 64 notification cap
| Originator: | moshefromsinai | ||
| Number: | rdar://31956308 | Date Originated: | 5/3/2017 |
| Status: | Open | Resolved: | |
| Product: | iOS + SDK | Product Version: | 10.3 |
| Classification: | Enhancement | Reproducible: | Always |
Area: UserNotifications Framework Summary: This is a long one, so I apologize in advance and thank you for your time. I'm happy to answer any questions that might be useful. I have two apps which send alerts based on sunrise and sunset. To trigger at the correct time, I can't use any repeating trigger, since none account for sunrise or sunset. One app runs notifications for a specific 7 weeks, scheduling two notifications for those 49 days. Another runs a set of reminders based on sunrise and sunset every day of the year. To work around this, I need to calculate the correct time and use a calendar trigger, scheduling one notification per day. Then, I can schedule as many notifications as iOS allows, which is a pithy 64. For example, if I want to schedule a notification every day, one hour after sunrise, where an hour is a fixed length of 60 minutes, there's no way to do it with a single notification request. So, I schedule one for sunrise tomorrow, and one for the day after and so on. As time goes on, those notifications begin to fire, and eventually, all 64 will be delivered and my user will stop receiving notifications. To continue receiving notifications, my user needs to open up the app at least once in the 64 days to reschedule notifications further out into the future. This is sort of okay, because users that care about my app will hopefully open it at least once every 2 months, but with Watch, and Today Widgets, and my notifications, users are less likely to do so. Also, if my user wants two notifications, such as one an hour after sunrise and one an hour before sunset, I now need to use TWO requests per day. Now my user needs to open up the app once a month, instead of once every other month. In my case, there are at least half a dozen different notifications that my user can enable, so they need to open the app weekly for this to work. Essentially, it gets increasingly difficult and increasingly complicated to schedule notifications that trigger not just on time or region, but on a combination of both. One of three things would improve this situation for me: 1. Remove the 64 request cap, so I can keep on calculating notifications out into the future. 2. Allow me to write a custom notification trigger 3. Add a SunriseSunsetOffset trigger to the framework. Steps to Reproduce: Case 1: - Schedule notifications at sunset every day for a year by running a loop that calculates sunset and passes that to a UNCalendarTrigger. (See the attached code for an example.) - Fetch the pending requests - Count them Case 2: - Attempt to subclass UNNotificationTrigger and vend your own fire date and repeat rules based on sunrise or sunset. Case 3: - Attempt to use a sunrise based calendar trigger. Expected Results: Case 1: - All pending requests should be scheduled Case 2: - Notifications scheduled with a custom trigger should call the callback block. Case 3: - A sunrise/sunset trigger should exist. Actual Results: Case 1: - Observe that only the most recent 64 requests are pending (at the end of the year, so the user will be unlikely to ever see them.) Case 2: - There's no way to do this as of iOS 10.3. UserNotificationCenter.current().add(_, withCompletionHandler:) doesn't call the completion block with an error. It silently fails. Case 3: - There's no such trigger. Version: iOS 10.3 Notes: In the attached file ReminderManager.swift, there's a method called scheduleRemindersInALoop() which schedules a fixed reminder, and a badging-only reminder for sunset every day. In this case I want the badging to happen every day for 49 days. That, coupled with a fixed reminder for those same 49 days, means that I have a total of 98 reminders that can't be repeated on a repeating trigger. Alarm Manager.zip is equivalent UILocalNotification code, illustrating the same challenge in the case of N daily sun-based notifications. I understand that it's using the older API but I think it's useful context to have. If you're still reading, I really appreciate your time, and I'm happy to answer any questions you have. Moshe Berman, ---.---.---- (----- Time Zone, best to talk after 4PM Pacific) Configuration: iPhone 6s, Verizon Attachments: 'Alarm Manager.zip' and 'ReminderManager.swift' were successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!