Menu

1 / 2

5 timing bugs I hit building timed blocks with Screen Time's DeviceActivity (iOS)

DEV Community: reactnative·ayumu kitabayashi·1 day ago
#SEMYXZYj
#devtoreactnative#devto#dev#start#minute
Reading 0:00
15s threshold

I build minulo, an iPhone app that hides Reels and Shorts. One feature is a timed block: lock the official Instagram app with Screen Time for, say, 30 minutes, and have it unlock on its own even if minulo isn't running. That part runs on DeviceActivity (DeviceActivityCenter.startMonitoring + a DeviceActivitySchedule, with the unlock happening in a DeviceActivityMonitor extension's intervalDidEnd).

It took five rounds of bugs to get the timing right. All five are about how the schedule's start and end are interpreted, so they apply whether you write Swift directly or go through a wrapper like react-native-device-activity (which I use, with my own additions).

1. Windows shorter than 15 minutes are rejected

Pass a 5-minute window to startMonitoring and you get an error. In my testing on device, anything under 15 minutes was refused.

My first workaround was "now + 15 minutes", which meant a 5-minute break stayed unlocked for 15.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.