Add push notifications via local sync loop and FCM

Local notifications:
- NotificationHelper posts per-room notifications from the sync loop
- Notifications suppressed when room is active (ChatScreen DisposableEffect)
- Deferred for encrypted rooms until room key arrives; fires with real body
- Notification tap navigates to the room via pendingRoomId StateFlow
- POST_NOTIFICATIONS permission requested at runtime (API 33+)

FCM push (app killed):
- MatrixFirebaseMessagingService handles token refresh and data messages
- Pusher registered with homeserver pointing to Cloudflare Worker gateway
- gateway/src/index.js: Cloudflare Worker forwards Matrix pushes to FCM v1 API
  using a service-account JWT signed with Web Crypto
- last_sync_token persisted in SharedPreferences so restored sessions start with
  an incremental sync and fire notifications immediately (fixes missed-on-wake bug)
- Default FCM notification channel declared in manifest

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ltadeu6 2026-05-17 19:55:59 -03:00
parent 1f5e6ca691
commit de6386d614
15 changed files with 489 additions and 5 deletions

View file

@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.google.services)
}
android {
@ -64,6 +65,8 @@ dependencies {
implementation(libs.androidx.browser)
implementation(libs.androidx.appcompat)
implementation(files("libs/olm-sdk-3.2.16.jar"))
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.messaging)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.okhttp.logging)
}