收口移动壳通知桥接边界
将 Expo 本地通知 payload 归一收口到 notifications 模块 让移动壳 dispatch 只委托通知 HostBridge 请求 同步移动壳结构门禁、架构文档和共享记忆
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
||||
type HapticsImpactPayload,
|
||||
HOST_BRIDGE_VERSION,
|
||||
type HostBridgeRequest,
|
||||
normalizeHostBridgeLocalNotification,
|
||||
} from '../../../../packages/shared/src/contracts/hostBridge';
|
||||
import { MOBILE_SHELL_HOST_VERSION } from '../shell/runtime';
|
||||
import { resolveMobileHostCapabilities } from './capabilities';
|
||||
@@ -28,7 +27,7 @@ import {
|
||||
} from './protocol';
|
||||
import { resetQrScannerForTest, scanQrCode } from './scanner';
|
||||
import { openShare } from './share';
|
||||
import { showMobileLocalNotification } from './notifications';
|
||||
import { showMobileHostBridgeLocalNotification } from './notifications';
|
||||
import {
|
||||
readMobileHostBridgeClipboardText,
|
||||
writeMobileHostBridgeClipboardText,
|
||||
@@ -64,15 +63,6 @@ async function runHaptics(payload: unknown) {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function showLocalNotification(payload: unknown) {
|
||||
const notification = normalizeHostBridgeLocalNotification(payload);
|
||||
if (!notification) {
|
||||
throw invalidRequest('title is required');
|
||||
}
|
||||
|
||||
return showMobileLocalNotification(notification);
|
||||
}
|
||||
|
||||
function getMobileRuntimePlatform() {
|
||||
return Platform.OS === 'ios' ? 'ios' : 'android';
|
||||
}
|
||||
@@ -130,7 +120,10 @@ export async function dispatchMobileHostBridgeRequest(
|
||||
case 'haptics.impact':
|
||||
return ok(request, await runHaptics(request.payload));
|
||||
case 'notification.showLocal':
|
||||
return ok(request, await showLocalNotification(request.payload));
|
||||
return ok(
|
||||
request,
|
||||
await showMobileHostBridgeLocalNotification(request.payload),
|
||||
);
|
||||
case 'app.setBadgeCount':
|
||||
return ok(request, setMobileAppBadgeCount(request.payload));
|
||||
case 'share.open':
|
||||
|
||||
@@ -5,7 +5,9 @@ import {
|
||||
HOST_BRIDGE_MOBILE_LOCAL_NOTIFICATION_CHANNEL_ID,
|
||||
type HostBridgeError,
|
||||
type LocalNotificationPayload,
|
||||
normalizeHostBridgeLocalNotification,
|
||||
} from '../../../../packages/shared/src/contracts/hostBridge';
|
||||
import { invalidRequest } from './protocol';
|
||||
|
||||
Notifications.setNotificationHandler({
|
||||
handleNotification: async () => ({
|
||||
@@ -69,3 +71,12 @@ export async function showMobileLocalNotification(
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function showMobileHostBridgeLocalNotification(payload: unknown) {
|
||||
const notification = normalizeHostBridgeLocalNotification(payload);
|
||||
if (!notification) {
|
||||
throw invalidRequest('title is required');
|
||||
}
|
||||
|
||||
return showMobileLocalNotification(notification);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user