Skip to content

fix(notify): stop alerts from being lost, replaced or held back - #615

Merged
whes1015 merged 5 commits into
mainfrom
fix/notification-delivery
Oct 16, 2026
Merged

whes1015 merged 5 commits into
mainfrom
fix/notification-delivery

Conversation

@whes1015

@whes1015 whes1015 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Stack 第 1/5 層:#615 → #618 → #619 → #620 → #621,請由下往上合併(#614、#616 已合併)。這是最底層,base 是 main。

這個 PR 做了什麼

修正幾個讓通知「送到了卻沒被看到」的問題:Android 上不同警報互相覆蓋、未知頻道的推播落到「其他」類別、舊版留下的死頻道,以及 iOS 的專注模式擋下重要通知。另外在 iOS 設定的 DPIP 通知頁加上連回 app 通知設定的入口。

改動內容

正式程式碼

  • bb8fa520 超大通知 id 不再變成 0(Android)
    • 後端的通知 id 常是 40 位元,_asNotificationId 超出 32 位元就回傳 null,最後一律變成 0。同時到達的速報、震度速報和天氣警特報因此擠在同一個通知位置,只剩最後一則。
    • 改成取低 31 位元;沒有 id 或 id 不是數字時,用頻道、標題和內容算出穩定的雜湊,不再是 0。
    • app 被關掉時的路徑原本把原始 id 直接交給 awesome_notifications,它會拒絕並靜靜回傳 false,推播就不見了。現在先把 content.id 改寫好再交出去,失敗會記 log。
  • 11e03e0a 預設 FCM 頻道(Android)
    • AndroidManifest.xml 加上 com.google.firebase.messaging.default_notification_channel_id,指向 announcement-general-v2。
    • 系統直接畫出來的推播如果指定了 app 不認得的頻道,原本會落到 FCM 的「Miscellaneous」,重要性也只有預設。
  • 6f021131 刪除舊版留下的頻道(Android)
    • RetiredChannels.keys 列出從 git 歷史找到的 51 個舊頻道 id,也涵蓋 awesome 用 <key>_<md5> 形式註冊的版本。
    • 執行時會和目前的頻道清單比對,絕不會刪到還在用的頻道;有測試鎖住這一點。
    • PlainChannelsChannel.kt 新增 list 和 delete。清理放在頻道設定的最後,已經乾淨的手機只多一次呼叫。
  • 2468b353 iOS 加上 time-sensitive entitlement
    • Runner.entitlements 和 RunnerRelease.entitlements 都加上 com.apple.developer.usernotifications.time-sensitive。
    • awesome 會把 High/Max 頻道標成 .timeSensitive,但沒有這個 entitlement,iOS 會把它們當一般通知,專注模式和睡眠時會擋下。影響範圍是所有沒開重大警報的頻道(強震即時警報、震度速報、海嘯一般、大雷雨、豪雨、疏散避難),以及拒絕重大警報授權的使用者收到的所有速報。
    • 有測試同時檢查兩個檔案,避免只改到其中一個。
  • 676cff14 iOS 設定連回 app 通知設定
    • NotificationSettingsLinkPlugin.swift:只在通知已授權時才多要求這個選項,使用者不會看到任何對話框;重大警報不在這次要求內。
    • NotificationDelegateProxy 把設定頁那一列的點擊轉給 Dart;app 被這個點擊啟動時也會補送。
    • routeNotificationSettingsLink:在目前畫面上方開通知設定頁;已經開著就不重複開,新手引導期間不動作。

測試

  • content_from_data_test.dart、notification_service_test.dart:id 對應、非數字 id、app 被關掉時的路徑。
  • fcm_default_channel_test.dart:預設頻道必須是頻道清單裡真的存在的頻道(改壞會失敗,已驗證)。
  • retired_channels_test.dart:舊頻道清單不包含任何目前使用中的頻道。
  • ios_entitlements_test.dart:兩個 entitlements 檔都有 time-sensitive。
  • notification_settings_link_test.dart、notification_routes_test.dart、onboarding_permissions_test.dart:導向行為。

相關 issue

沒有對應的 issue,是檢查通知送達路徑時發現的。

怎麼驗

  • tool/commit.sh --push 通過(analyze、codegen、全部 Dart 測試)。
  • tool/dev/test_ios.sh:370 個 XCTest 全部通過,新的 Swift 檔有一起編譯。
  • 合併前必須先做(否則正式版簽章會失敗): 在 Apple Developer 後台 Identifiers → com.exptech.dpip.dpip 開啟 Time Sensitive Notifications。release workflow 用 -allowProvisioningUpdates 自動簽章,開啟後描述檔會自動更新;PR 的 iOS CI 用 --no-codesign,所以抓不到這個問題。
  • 後端: 遠端推播要帶 interruption-level: time-sensitive 才有效,這部分在後端另外處理。沒部署前,entitlement 只對 app 自己發的本機通知有效。
  • 還沒在實機上測,建議做:
    • Android、app 被關掉時:40 位元 id 的推播會顯示;同時送兩則不同警報,兩則都留在通知欄;指定未知頻道的推播落在「公告」。
    • Android 從舊版升級:系統設定裡只剩 -v2 頻道,log 有「deleted N retired channel(s)」。
    • iOS 開專注模式:High/Max 通知能穿過(需要後台開好 capability、後端部署)。
    • iOS 設定 → DPIP → 通知:出現連回 app 的那一列,點了會開 app 的通知設定,冷啟動和 app 開著時都只開一次。

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
  • 一個 commit 一件事
  • analyze 與測試通過(tool/commit.sh --push)
  • 沒有新的使用者可見字串(iOS 設定那一列的文字由系統提供)
  • 沒有 UI 版面變更

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.97980% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.47%. Comparing base (807f5d9) to head (676cff1).
⚠️ Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
lib/app/app.dart 60.00% 2 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@whes1015

Copy link
Copy Markdown
Member Author

Force-push:rebase 到目前的 main(807f5d9d),並把開著的 PR 排成 stack:#614 → #616 → #615 → #618 → #619 → #620 → #621,base 改成下面那一層的分支。

和 main 及其他 PR 的衝突都是兩邊各自新增的內容,雙方都保留;ARB 在檔尾補逗號後重新產生 l10n。每一層都單獨跑過 analyze 和完整測試,頂端跑過 tool/commit.sh --push。

這一層的 commit 內容沒有變,只有上下文不同。

@whes1015
whes1015 added this pull request to stack #626 October 16, 2026 19:21
@whes1015
whes1015 force-pushed the fix/notification-delivery branch from c8ca126 to 2addde0 Compare October 16, 2026 19:31
@whes1015

Copy link
Copy Markdown
Member Author

Force-push:#614 合併後 rebase 到新的 main(238297ea),拿掉 #614 合併前的舊 commit。

內容沒有變:main 上合併進來的 tree 和 stack 第一層完全相同,搬過去之後每一層的 tree 也都和之前一樣,所以先前各層的 analyze 和測試結果仍然有效。

Base automatically changed from fix/eew-cancel-and-ordering to main October 16, 2026 19:33
Platform: android

Fix(zh-Hant): 修正同時收到多則警報時,前一則會被下一則蓋掉,通知欄只剩最後一則
Fix(en-US): fix alerts arriving together replacing one another so only the last stayed in the notification shade
Platform: android

Fix(zh-Hant): 修正系統代為顯示的推播指定了不認得的類別時,會落到「其他」並使用系統預設音效
Fix(en-US): fix pushes the system shows for an unknown category landing in "Miscellaneous" with the default sound
Platform: android

Fix(zh-Hant): 修正升級後系統通知設定裡留著舊版的重複通知類別,關掉它們其實沒有任何作用
Fix(en-US): fix upgraded phones listing leftover duplicate notification categories in system settings that no longer control anything
Platform: ios

Fix(zh-Hant): 修正 iOS 開啟專注模式或睡眠模式時,地震速報等即時警報會被擋下、等解除後才出現
Fix(en-US): fix time-sensitive alerts such as earthquake warnings being held back by Focus or Sleep on iOS
Platform: ios

New(zh-Hant): iOS「設定」裡 DPIP 的通知頁面多了一個連結,點了會直接打開 app 內的通知設定
New(en-US): iOS Settings now links from DPIP's notification page straight to the app's own notification settings
@whes1015
whes1015 force-pushed the fix/notification-delivery branch from 2addde0 to 676cff1 Compare October 16, 2026 19:37
@whes1015

Copy link
Copy Markdown
Member Author

Force-push:#616 合併後 rebase 到新的 main(34336fb6),拿掉 #616 合併前的舊 commit。

內容沒有變:main 上合併進來的 tree 和 stack 第一層完全相同,搬過去之後每一層的 tree 也都和之前一樣。push 前 gate 全過。

@whes1015
whes1015 merged commit 53519c7 into main Oct 16, 2026
6 checks passed
@whes1015
whes1015 deleted the fix/notification-delivery branch October 16, 2026 19:43
@lowrt lowrt added this to the v26.4 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants