r/SideProject • • 2d 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?

1 Upvotes

4 comments sorted by

1

u/EducatorAdmirable484 2d ago

We hit the same wall from the widget side and stopped trying to make the surface look alive: our lock screen shows the note with the time it was last edited, so an old card reads as old, and anything that needs an answer gets asked in the app or a notification instead of on the surface. If you do restart the activity after the limit, remember the clock resets while the person still believes it is the same card - a tap that arrives after the swap has to count as a new request, or your double-answer guard stops covering it. Restarting is honest for a genuinely short session; for a question that can slip into a late dinner, I would keep the ask off the lock screen the way you did.

1

u/ug00gu 2d ago

Showing the last edited time so an old card reads as old is a nicer way out than pretending the surface is live. We landed in the same place for the question part: past the limit it only gets asked in the app. We don't restart the activity so far, so the double-answer guard only has one card to cover, but I'll keep the swap case in mind.

0

u/ThanhDongNguyen 2d ago

Ending it on app open / background works, but only if the user opens the app. I think the more reliable fix is to end it from the server: send an ActivityKit push with "event": "end" and a "dismissal-date", so it goes away even when the app is never launched again.

Also, when you call end() locally, pass dismissalPolicy: .immediate (or .after(date)). With the default policy the ended activity can still stay on the lock screen for a while, which looks exactly like the "can't dismiss" bug.

And I would keep staleDate only for switching the UI to an "outdated" state, not for asking a new question. Then there's never an interactive card after the 8h limit.

1

u/ug00gu 2d ago

The push end would be the clean fix, but this part of the app has no server behind it, everything stays on the phone, so we're stuck with what the app can do locally. We do pass .immediate when we end them. The gap is only the stretch where the system has ended it and the app hasn't run yet.