Show decrypted notification bodies and authenticated sender avatars.
All checks were successful
Build / increment-version (push) Successful in 5s
Build / build-android (push) Successful in 5m8s

Wait for E2EE cleartext before building tray text, and post Android notifications natively so dynamic avatars fetched with secure media auth can appear as large icons.
This commit is contained in:
2026-07-24 14:47:32 +10:00
parent a40319e8c8
commit cfabcc5fbf
5 changed files with 384 additions and 132 deletions

View File

@@ -64,6 +64,16 @@ interface MatrixBackgroundSyncPlugin {
{ groupId: string; groupName: string; roomName: string; kind: string }
>;
}): Promise<{ success: boolean }>;
/** Post a message notification with optional avatar (base64) from the JS layer. */
showNotification(options: {
title: string;
body: string;
roomId: string;
groupId: string;
groupName: string;
kind: string;
largeIconBase64?: string;
}): Promise<{ shown: boolean }>;
addListener(
eventName: 'unifiedPushNewEndpoint',
listenerFunc: (event: UnifiedPushEndpointEvent) => void
@@ -564,3 +574,27 @@ export const syncNotificationGroupMap = async (
console.warn('[BackgroundSync] setNotificationGroups failed:', err);
}
};
/**
* Posts a native tray notification (supports dynamic/authenticated avatar icons).
* Prefer this over Capacitor LocalNotifications on Android.
*/
export const showNativeNotification = async (options: {
title: string;
body: string;
roomId: string;
groupId: string;
groupName: string;
kind: string;
largeIconBase64?: string;
}): Promise<boolean> => {
if (!isBackgroundSyncSupported()) return false;
try {
await MatrixBackgroundSync.showNotification(options);
return true;
} catch (err) {
console.warn('[BackgroundSync] showNotification failed:', err);
return false;
}
};