The author describes a scenario where an HTML timer created by ChatGPT fails to work when the phone screen turns off. This is due to platform decisions: setTimeout and setInterval are throttled or frozen when a tab goes into the background, and the Notifications API cannot schedule notifications for a specific time.
Web Push notifications, available on iOS 16.4+ for PWA, require a server with HTTPS, VAPID, and subscriptions, making them impractical for simple local timers. The Notification Triggers specification was tested by Chrome in 2020–2021 but the project was closed.
To solve this problem for personal tools, the author created Kapsula, a free app available on Android and iOS. It runs HTML in an isolated iframe and provides a native bridge (window.kapsula) to access system alarms (AlarmManager on Android and local notifications on iOS).
Kapsula allows scheduling up to 16 alarms per project. The logic works by passing the schedule to the OS, as JavaScript does not execute in the background. When the screen is on, live JS handles the timing; when the screen is off or the app is minimized, the OS triggers the notification. Kapsula does not support background code execution, voice prompts with the screen off, or server-side push notifications.





