统一移动通知频道契约

将移动端 Android 本地通知频道提升到共享 HostBridge 契约

让 Expo 通知调度和测试复用共享频道标识

增加移动壳配置门禁防止通知频道回退到本地字面量

补充宿主壳方案文档和共享决策记录
This commit is contained in:
2026-06-19 14:37:02 +08:00
parent b6b1e21211
commit e51a65138a
8 changed files with 45 additions and 12 deletions
@@ -16,6 +16,7 @@ import { afterEach, describe, expect, test, vi } from 'vitest';
import {
HOST_BRIDGE_BADGE_COUNT_MAX,
HOST_BRIDGE_MOBILE_LOCAL_NOTIFICATION_CHANNEL_ID,
HOST_BRIDGE_PROTOCOL,
HOST_BRIDGE_RESPONSE_CACHE_MAX,
HOST_BRIDGE_VERSION,
@@ -738,7 +739,7 @@ describe('handleMobileHostBridgeMessage', () => {
expectOk(response);
expect(Notifications.setNotificationChannelAsync).toHaveBeenCalledWith(
'genarrative-local',
HOST_BRIDGE_MOBILE_LOCAL_NOTIFICATION_CHANNEL_ID,
{
name: 'Genarrative',
importance: Notifications.AndroidImportance.DEFAULT,
@@ -749,7 +750,7 @@ describe('handleMobileHostBridgeMessage', () => {
title: '生成完成',
},
trigger: {
channelId: 'genarrative-local',
channelId: HOST_BRIDGE_MOBILE_LOCAL_NOTIFICATION_CHANNEL_ID,
},
});
});
@@ -13,6 +13,7 @@ import {
type ClipboardWriteTextPayload,
type HapticsImpactPayload,
HOST_BRIDGE_BADGE_COUNT_MAX,
HOST_BRIDGE_MOBILE_LOCAL_NOTIFICATION_CHANNEL_ID,
HOST_BRIDGE_VERSION,
type HostBridgeError,
type HostBridgeRequest,
@@ -51,8 +52,6 @@ import { resetQrScannerForTest, scanQrCode } from './scanner';
import { openShare } from './share';
import { buildMobileShellUrl } from '../shell/url';
const LOCAL_NOTIFICATION_CHANNEL_ID = 'genarrative-local';
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowBanner: true,
@@ -193,7 +192,7 @@ async function showLocalNotification(payload: unknown) {
await ensureNotificationPermission();
if (Platform.OS === 'android') {
await Notifications.setNotificationChannelAsync(
LOCAL_NOTIFICATION_CHANNEL_ID,
HOST_BRIDGE_MOBILE_LOCAL_NOTIFICATION_CHANNEL_ID,
{
name: 'Genarrative',
importance: Notifications.AndroidImportance.DEFAULT,
@@ -205,7 +204,7 @@ async function showLocalNotification(payload: unknown) {
content: notification,
trigger:
Platform.OS === 'android'
? { channelId: LOCAL_NOTIFICATION_CHANNEL_ID }
? { channelId: HOST_BRIDGE_MOBILE_LOCAL_NOTIFICATION_CHANNEL_ID }
: null,
});
return true;