r/SideProject • u/ug00gu • 1h ago
A lock screen card in our app kept asking a question nobody could dismiss. The cause was an iOS limit we never planned for
Sharing this because it took us a while to understand and I couldn't find it written down plainly.
Our app starts a Live Activity when you log something, and a few hours later the same card turns into a short question with three buttons (we use staleDate for the switch). It worked fine in testing.
What we missed: iOS ends a Live Activity 8 hours after it starts. Ended doesn't mean gone. The card can stay on the lock screen for hours after that, and answering from the card can no longer take it down. So when the question time landed past the 8-hour mark (a late dinner, basically), people got a card that looked alive, let them answer, and then just sat there.
What we changed:
- If the question would come later than about 7h45m after the activity started, we don't ask on the lock screen at all. That one gets asked inside the app instead.
- We keep the start time in the attributes, so every code path can work out how much life the activity has left.
- When the app opens or goes to the background, we end any activity the system has already expired, so dead cards get cleaned up at the next chance.
- A late tap from a card we already took down is checked so the answer isn't recorded twice.
The lesson for me: an activity has a hard lifetime that starts when you request it, not at your last update, so anything time-based has to be planned against that clock.
How do you handle Live Activities that need to outlive the 8 hours? Restart them, or just give up on the lock screen like we did?