diff --git a/app/src/main/java/app/closer/MainActivity.kt b/app/src/main/java/app/closer/MainActivity.kt index cd07813a..ef501675 100644 --- a/app/src/main/java/app/closer/MainActivity.kt +++ b/app/src/main/java/app/closer/MainActivity.kt @@ -129,6 +129,7 @@ class MainActivity : AppCompatActivity() { questionId = intent.getStringExtra("question_id"), conversationId = intent.getStringExtra("conversation_id"), gameSessionId = intent.getStringExtra("game_session_id"), + gameType = intent.getStringExtra("game_type"), capsuleId = intent.getStringExtra("capsule_id"), challengeId = intent.getStringExtra("challenge_id"), avatarUrl = intent.getStringExtra("sender_avatar_url") diff --git a/app/src/main/java/app/closer/core/notifications/AppMessagingService.kt b/app/src/main/java/app/closer/core/notifications/AppMessagingService.kt index f459ec75..ac7e5bcf 100644 --- a/app/src/main/java/app/closer/core/notifications/AppMessagingService.kt +++ b/app/src/main/java/app/closer/core/notifications/AppMessagingService.kt @@ -78,6 +78,7 @@ class AppMessagingService : FirebaseMessagingService() { questionId = message.data["question_id"], conversationId = message.data["conversation_id"], gameSessionId = message.data["game_session_id"], + gameType = message.data["game_type"], capsuleId = message.data["capsule_id"], challengeId = message.data["challenge_id"], avatarUrl = message.data["sender_avatar_url"] diff --git a/app/src/main/java/app/closer/notifications/PartnerNotificationManager.kt b/app/src/main/java/app/closer/notifications/PartnerNotificationManager.kt index e86640ac..ad4eef99 100644 --- a/app/src/main/java/app/closer/notifications/PartnerNotificationManager.kt +++ b/app/src/main/java/app/closer/notifications/PartnerNotificationManager.kt @@ -9,6 +9,7 @@ import androidx.core.app.NotificationManagerCompat import app.closer.MainActivity import app.closer.R import app.closer.core.navigation.AppRoute +import app.closer.domain.model.GameType import app.closer.domain.repository.AppSettings import app.closer.domain.repository.SettingsRepository import dagger.hilt.android.qualifiers.ApplicationContext @@ -267,8 +268,16 @@ enum class PartnerNotificationType( fun routeFor(payload: PartnerNotificationPayload, coupleId: String = ""): String = when (this) { PARTNER_ANSWERED -> AppRoute.DAILY_QUESTION REVEAL_READY -> payload.questionId?.let { AppRoute.answerReveal(it) } ?: AppRoute.ANSWER_HISTORY - PARTNER_STARTED_GAME -> AppRoute.PLAY - PARTNER_COMPLETED_PART -> AppRoute.PLAY + // Deep link straight into the waiting game (each game screen auto-joins the couple's active + // session on open), not the generic Play hub — the push says "Tap to join". Falls back to the + // hub only if the server didn't send game_type. E-003. + PARTNER_STARTED_GAME -> gameRouteForType(payload.gameType) ?: AppRoute.PLAY + PARTNER_COMPLETED_PART -> gameRouteForType(payload.gameType) ?: AppRoute.PLAY + // Results-ready means the session is COMPLETED, so the plain game route would show "start a + // new game" (getActiveSession returns only active sessions). The correct target is the + // per-session results/replay route — but that needs the server to also send game_session_id + // in the FCM data (currently it sends only game_type). Until that server change ships, route + // to the Play hub rather than a misleading setup screen. E-003 (results-ready follow-up). GAME_RESULTS_READY -> AppRoute.PLAY CHALLENGE_WAITING -> AppRoute.CONNECTION_CHALLENGES CAPSULE_UNLOCKED -> AppRoute.MEMORY_LANE @@ -326,8 +335,23 @@ data class PartnerNotificationPayload( val questionId: String? = null, val conversationId: String? = null, val gameSessionId: String? = null, + /** The active session's game type (e.g. "this_or_that"), used to deep link into the game. E-003. */ + val gameType: String? = null, val capsuleId: String? = null, val challengeId: String? = null, /** Sender's avatar URL, used as the notification large icon when present. */ val avatarUrl: String? = null ) + +/** + * Maps a session's [GameType] to the entry route that resumes/joins it. Each game screen detects the + * couple's active session on open and joins it, so deep linking here drops the partner straight into + * the waiting game (mirrors HomeViewModel.gameRouteFor for the Home "Play now" CTA). E-003. + */ +private fun gameRouteForType(gameType: String?): String? = when (gameType) { + GameType.WHEEL -> AppRoute.SPIN_WHEEL_RANDOM + GameType.THIS_OR_THAT -> AppRoute.THIS_OR_THAT + GameType.HOW_WELL -> AppRoute.HOW_WELL + GameType.DESIRE_SYNC -> AppRoute.DESIRE_SYNC + else -> null +}