Skip to content

feat(A2): 真 FCM 推播——App 被殺點推播可喚醒接單卡 - #38

Merged
thothawei merged 1 commit into
mainfrom
claude/dispatch-fcm-pusher
Jul 18, 2026
Merged

thothawei merged 1 commit into
mainfrom
claude/dispatch-fcm-pusher

Conversation

@thothawei

Copy link
Copy Markdown
Owner

後端原本只有 LogPusher stub。實作 FCMPusher(Firebase Admin SDK),讓司機 App 被殺/背景時系統匣顯示派單通知,點擊喚醒 App 直達接單卡(A2)。

改動

  • notify.AppPusher.SendRideOffer 加 data map[string]string;Dispatcher.NotifyDriverRideOffer 一路帶下去;LogPusher 記錄 data
  • internal/notify/fcm.go:FCMPusher 用 messaging Notification+Data+Android high priority;只送 FCM platform token;逐台判斷失敗(單台 token 失效不影響其他台),全數失敗才回錯
  • dispatch.go rideOfferPushData:組推播 data,值一律字串(FCM 限制),欄位對齊 rideAssignedPayload 但不帶 stops——結構化陣列不塞 FCM data,App 接單後重讀 rides/active 補齊全程(見 fleet-app#32)
  • config FCM_CREDENTIALS_FILE;main.go 有憑證才啟用,初始化失敗只打 log 降級 stub(憑證問題不讓服務起不來、派單路徑不受影響)
  • 測試:rideOfferPushData 字串化+不帶 stops+無 dropoff 省略;notify recordingPusher 斷言 data 一路帶到 pusher

驗收

  • go build ./...、go vet ./... 通過
  • internal/notify、internal/service(純函式)、internal/config 測試綠
  • FCMPusher 本身需真憑證/網路,改測純函式與介面串接;真裝置 E2E 待配 Firebase 專案

啟用方式

Firebase Console → 服務帳戶 → 產生私鑰 JSON → 掛進容器 → 設 FCM_CREDENTIALS_FILE。未設=stub(本地開發不必配 Firebase)。

🤖 Generated with Claude Code

後端原本只有 LogPusher stub。實作 FCMPusher(Firebase Admin SDK),
讓司機 App 被殺/背景時系統匣顯示派單通知,點擊喚醒 App 直達接單卡。

- notify.AppPusher.SendRideOffer 加 data map[string]string 參數;
  Dispatcher.NotifyDriverRideOffer 一路帶下去;LogPusher 記錄 data
- internal/notify/fcm.go:FCMPusher 用 messaging Notification+Data+
  Android high priority;只送 FCM platform token;逐台判斷失敗
  (單台 token 失效不影響其他台),全數失敗才回錯
- dispatch.go rideOfferPushData:組推播 data,值一律字串
  (FCM 限制),欄位對齊 rideAssignedPayload 但**不帶 stops**——
  結構化陣列不塞 FCM data,App 接單後重讀 rides/active 補齊全程
- config FCM_CREDENTIALS_FILE;main.go 有憑證才啟用,初始化失敗
  只打 log 降級 stub(憑證問題不讓服務起不來、派單路徑不受影響)
- 測試:rideOfferPushData 欄位字串化+不帶 stops+無 dropoff 省略;
  notify recordingPusher 斷言 data 一路帶到 pusher

go build/vet 通過;notify/service(純)/config 測試綠。FCMPusher 本身
需真憑證/網路無法單元測,改測純函式與介面串接。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@thothawei
thothawei merged commit 3ccd6db into main Jul 18, 2026
1 check passed
@thothawei
thothawei deleted the claude/dispatch-fcm-pusher branch July 18, 2026 19:15
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