fix(notif): game pushes deep-link into the waiting game, not the Play hub (E-003)
partner_started_game / partner_completed_part now route to the specific game route (gameRouteForType(payload.gameType)) so the game screen auto-joins the couple's active session — fulfilling the 'Tap to join!' promise. Server already sends game_type in the FCM data; client now parses it (AppMessagingService + MainActivity) into PartnerNotificationPayload and routeFor maps it. game_results_ready stays on the hub pending a server change to also send game_session_id (completed sessions aren't returned by getActiveSession, so the plain game route would show setup). Verified live: backgrounded partner tapped the start-game push -> opened This or That at 1/5 (joined), not the hub. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
a2b38485b1
commit
1b9d8cf8dc
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue