UILocalNotification & Do Not Disturb Settings

File this under "Totally Obvious, no doy."

The app I'm working on these days has user-specified timers. I've been dogfooding it now for a couple of months and periodically I would get these things where I'd stop getting the audio timer notifications and I'd burn some cookies or a loaf of bread or whatever. Every time I'd dutifully mail myself the log file and the next morning I would A ) not be able to reproduce the problem and B ) not see anything wrong in the log file. Then one day I finally figured out the common factor: I had turned on "Do Not Disturb" on my phone at 10 PM. I have no idea why, it's not like I ever go to sleep at 10 PM. While iOS's Clock app can make alert sounds during Do Not Disturb my app cannot.

My immediate problem was easy: I pushed Do Not Disturb until midnight and if I need a timer after midnight I need to use Apple's Clock app. But I have a bigger problem with the app: how do I educate the user about this issue and/or alert them when it is a problem? Well, the thing is the timer mostly runs via a scheduled UILocalNotification. If you're running TodayTimer in the foreground then I'm running timers directly in order to update the UI. But as soon as TodayTimer enters the background I schedule a UILocalNotification to go off when the timer finishes. If I could see that Do Not Disturb will be active when the timer completes then I could alert the user not to rely on the timer. This wouldn't be perfect in two cases: when the user manually turn on DnD or adjusts the scheduled DnD window; or when the device travels into a new timezone (because DnD works in local time-zones but the UILocalNotification is scheduled against GMT. I might check the time, decide it was safely outside the DnD window, but the phone could travel into the DnD window before the timer expired.) Still, both of those were going to be super-rare.

This is a great theory, but the problem is the OS doesn't expose the DnD settings. So I filed a bug report (Open Radar), as a good iOS ecosystem citizen. I can understand why they aren't letting my app override DnD, I don't want Clash of Clans having the ability to play noises because I haven't clicked the cow in the last hour or whatever. But I don't see any issue with letting me know when DnD is active. I guess I can see a concern that app developers would schedule around DnD then. I'd settle for the call that schedules the notification returning an error message letting me know that my sound isn't going to happen.

Anyway, something you want to know if you have time-critical notifications with sounds. Both the sound and the vibration are silently failed by DnD and I don't see an Apple-approved way of handling the situation. I'm going to have to write some terrible end-user text that nobody will read and then just put up the with complaints & bad reviews …