Skip to content

feat(notifications): add WebSocket push + local notifications#3

Open
renatobardi wants to merge 1 commit into
mainfrom
feat/notifications-websocket
Open

feat(notifications): add WebSocket push + local notifications#3
renatobardi wants to merge 1 commit into
mainfrom
feat/notifications-websocket

Conversation

@renatobardi

Copy link
Copy Markdown
Owner

What

Entrega de notificações via WebSocket (Phoenix Channel) + notificações locais (UserNotifications), sem APNs nem conta Apple Developer paga. Puxa para a Fase 4 o caminho de docs/notifications-spec.md (server já pronto).

  • Core/API/KuraEndpoint.swift — URL única do socket (DEBUG ws://127.0.0.1:4000 / prod wss://)
  • Core/Notifications/PushPayload.swift — model + parse defensivo do evento push
  • Core/Notifications/LocalNotifier.swift — wrapper UserNotifications (sem capability)
  • Core/Notifications/NotificationsClient.swift — SwiftPhoenixClient socket+channel, connect(userID:)/disconnect(), junta-se a notifications:<uid>
  • App/AppDelegate.swift — autorização no launch, observa authState, banner em foreground, tap abre popover
  • Info.plistNSAllowsLocalNetworking para ws://localhost em dev
  • SwiftPhoenixClient 5.3.5 via SPM

Why

A conta Apple Developer paga está travada e bloqueava o E2E de notificações (único caminho era APNs, que exige conta paga). Como o Kura é menu bar sempre aberto, não precisa de APNs: o server entrega em tempo real por WebSocket e o app dispara notificações locais. Destrava o fluxo agora; APNs entra por cima depois sem mudar o payload.

How

  • Auth do socket: Firebase ainda comentado no repo → path DEBUG conecta com user_id cru (aceito pelo server em test env); path de produção com Firebase ID token escrito-mas-comentado em NotificationsClient, espelhando o AuthManager. Params via closure para token fresco a cada reconexão.
  • Entrega: channel.on("push")PushPayloadLocalNotifier.show. Delegate mostra banner mesmo em foreground.
  • Ciclo de vida: AppDelegate assina AuthManager.shared.$authState via Combine.
  • Validação: xcodebuild build → BUILD SUCCEEDED. E2E contra kura-server em test env: passos no fim de docs/notifications-spec.md.

Fora de escopo (intencional): APNs/capability, deep-link por data.type (views Fase 4 ainda não existem), persistência de notificações.

🤖 Generated with Claude Code

Deliver kura-server pushes in real time without a paid Apple Developer
account: a menu bar app does not need APNs. NotificationsClient connects
to the Phoenix Channel notifications:<uid> and LocalNotifier surfaces
each "push" event via UserNotifications.

- KuraEndpoint: single source for the socket URL (DEBUG localhost / wss)
- PushPayload: defensive parse of the "push" event payload
- LocalNotifier: UserNotifications wrapper (no capability required)
- NotificationsClient: SwiftPhoenixClient socket+channel, connect/disconnect
- AppDelegate: request auth on launch, drive socket from authState
- Info.plist: NSAllowsLocalNetworking for ws://localhost in dev

DEBUG connects with raw user_id (server test env); the Firebase ID token
path is written-but-commented, mirroring AuthManager. APNs can be layered
on later without changing the payload. See docs/notifications-spec.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant