Auto-dismiss timer and screen-reader announcement for banner
epic-scenario-push-engagement-ui-task-006 — Add a configurable auto-dismiss timer (default 5 seconds) to the in-app-notification-banner using a countdown that cancels if the user taps. Announce the notification text via VoiceOver/TalkBack using a live region or accessibility-live-region-announcer (664) so screen reader users receive the notification without visual focus shift.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 2 - 518 tasks
Can start after Tier 1 completes
Implementation Notes
Manage the timer in the widget's State (StatefulWidget) or in the OverlayController that manages the OverlayEntry — prefer the controller so the widget itself stays lean. Use SemanticsService.announce(text, textDirection) as the lowest-level Flutter API, or delegate to accessibility-live-region-announcer (664) if the project already provides this abstraction. Do not use Semantics(liveRegion: true) on the banner container itself, as this can cause repeated announcements on every rebuild — call announce() once on widget mount instead. To pause the timer while a screen reader is active, check MediaQuery.of(context).accessibleNavigation or use the announcer service's isScreenReaderActive getter if available.
Ensure Timer is cancelled in dispose() to avoid calling setState on a disposed widget.
Testing Requirements
Write widget tests: verify the banner is removed from the widget tree after 5 pump-duration cycles matching the timer duration (use fake async). Verify the timer is cancelled when a tap is simulated via WidgetTester.tap and that the banner remains present after the original timeout period. Verify the auto-dismiss pauses when accessibility is active by mocking the announcer service. Write unit tests for the timer cancellation logic in isolation from the widget.
Manually test with VoiceOver (iOS simulator) and TalkBack (Android emulator): confirm the announcement is read aloud when the banner appears without focus shifting. Test boundary: set duration to 2 seconds and assert it clamps to 3 seconds; set to 60 seconds and assert it clamps to 30 seconds.
The in-app notification banner depends on a Supabase Realtime subscription to detect new notification records. If the subscription reconnects slowly after an app resume from background, or if Realtime delivery is delayed under high load, the banner may not appear within the 2-second acceptance criterion.
Mitigation & Contingency
Mitigation: Implement an explicit subscription reconnect handler on app foreground events using Flutter's AppLifecycleState.resumed hook, and add a polling fallback that queries for unread notifications once per app foreground event as a safety net against missed Realtime events.
Contingency: If Realtime proves unreliable in production, promote the polling fallback to the primary mechanism with a 30-second interval, accepting slight latency in exchange for reliability.
Cold-start deep linking (app not running when push notification is tapped) requires deferred navigation after the Flutter engine and Supabase session are fully initialised. If the deep link is consumed before authentication completes, the router may navigate to a protected route without a valid session, causing an error or redirect loop.
Mitigation & Contingency
Mitigation: Implement a deferred navigation queue in scenario-deep-link-router that holds the parsed deep-link target until the auth session restoration lifecycle event fires, following the existing deep-link-handler pattern used in the BankID and Vipps authentication flows.
Contingency: If deferred navigation is not achievable within the epic's scope, fall back to navigating the user to the notification centre (which is always accessible post-login) where the relevant notification record is visible and tappable.