Show decrypted notification bodies and authenticated sender avatars.
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:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user