I have developed a custom notification in Apex using a page reference to an Aura component, and it works fine (user clicks on notifications under the Bell icon top right and get forwarded to the aura component). But I cannot find a way how to cleanup old notifications, is there a way, please? The system doesn't cleanup automatically, it probably must be done programmatically. Thanks for any help Karel
My apex code: Messaging.CustomNotification notification = new Messaging.CustomNotification(); notification.setTitle('...'); notification.setBody('...'); notification.setSenderId(UserInfo.getUserId()); notification.setNotificationTypeId([SELECT Id FROM CustomNotificationType WHERE DeveloperName ... LIMIT 1].Id); User user = [SELECT Id FROM User WHERE ... LIMIT 1]; Map<String, Object> pageRef = new Map<String, Object>{ 'type' => 'standard__component', 'attributes' => new Map<String, Object>{ 'componentName' => 'c__...' }, 'state' => new Map<String, Object>{ 'c__jobId' => ..., 'c__userId' => ... } notification.setTargetPageRef(JSON.serialize(pageRef)); notification.send(new Set<String>{ user.Id });
then the Aura component: implemets="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,lightning:isUrlAddressable">